模板参数列表问题太少
Too few template-parameter-lists problem
谁能告诉我如何使以下伪代码与GCC4兼容?我想知道它在 MSVC 下是如何工作的......
typedef int TypeA;
typedef float TypeB;
class MyClass
{
// No base template function, only partially specialized functions...
inline TypeA myFunction<TypeA>(int a, int b) {} //error: Too few template-parameter-lists
template<> inline TypeB myFunction<TypeB>(int a, int b) {}
};
编码该结构的正确方法是:
typedef int TypeA;
typedef float TypeB;
class MyClass
{
template <typename T>
T myFunction( int a, int b );
};
template <>
inline TypeA MyClass::myFunction<TypeA>(int a, int b) {}
template <>
inline TypeB MyClass::myFunction<TypeB>(int a, int b) {}
请注意,模板成员函数必须在类声明中声明,但专用化必须在类声明之外的命名空间级别定义。
相关文章:
- 在没有参数列表的情况下使用模板名称"Event"无效,模板问题
- C++关于ENUM的问题。我得到的响应比枚举列表大
- 替代在python中制作邻接列表与图形问题的字典?(如 C++ 中的 vector<vector<int&g
- 在C++中循环访问自定义结构列表的小问题
- 关于Stroustrup C++书的自动和{}列表问题
- 将值推送到 getter 函数调用的列表中时出现问题
- 使用初始化列表填充C++中的多维结构数组时出现问题
- 在 c++ 中访问列表向量时出现问题
- 有关具有编译错误的操纵列表的问题
- C++:继承和列表函数作为类成员的问题
- C++ 入门加列表:10.9 "顶部"指针问题
- 尝试使用初始值设定项列表构造"std::vector"的问题
- 自己的C++列表类实现(插入函数)出现问题
- 链接的列表字符串分类问题
- C 链接列表和总和问题
- C++有问题的函数,数组到列表
- 从一系列问题列表中生成输入(x)问题
- 析构函数问题 + 列表显示
- 显示条件有问题?(列表中的对象)
- 信号发出问题-列表视图没有显示完整的列表