模板参数列表太少问题
谁能告诉我如何使以下伪代码与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) {}
};
Can anybody please tell me how to make the following pseudo-code compatible with GCC4? I wonder how it works under 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) {}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对该构造进行编码的正确方法是:
请注意,模板成员函数必须在类声明的内部进行声明,但特化必须在其外部的命名空间处定义等级。
The proper way of coding that construct would be:
Note that the template member function has to be declared inside the class declaration, but specializations must be defined outside of it, at namespace level.