如何继承模板结构operator()
How to inherit template struct operator()?
我试了试
template<class T>
struct getData
{
boost::shared_ptr<T> operator()()
{
return boost::shared_ptr<T>(new T());
}
};
struct getVector : public getData<std::vector<int>>{};
我想指定()
通过继承返回…但它似乎没有返回期望的类型。我做错了什么?
你不需要返回类型是
吗?boost::shared_ptr<T> operator()()
^^^^^^^^^^^^^^^^^^^^
{
return boost::shared_ptr<T>(new T());
}
相关文章:
- 如何循环打印顶点结构
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 预处理器:插入结构名称中的前一个行号
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 孤立代码块在结构中引发异常
- 有什么方法可以遍历结构吗
- 如何在 C# 中映射双 C 结构指针?
- 如何在C++中使用结构生成映射
- 无法将结构注册为增强几何体3D点
- 多成员Constexpr结构初始化
- C++将文本文件中的数据读取到结构数组中
- 如何重构类层次结构以避免菱形问题
- 无法使用"enable_if"和"is_base_of"将模板函数"operator+"的重载限制到我的类层次结构
- 对新结构的Oploading Operator()
- 我得到"将值分配给结构数组 iin 时与'operator='不匹配C++
- 如何在使用vector::operator[]迭代结构的向量时访问结构成员
- 将元素添加到遇到的结构数组C++"error no match for ‘operator=’"
- 如何继承模板结构operator()
- 在结构体内部定义operator()函数