Olu*_*ide 1 c++ templates function-templates default-arguments
以下位代码在GCC 4.5.3中编译,但不在VS 2008和2010中编译.这是由于VS编译器错误还是标准禁止给出默认函数模板参数值?
#include <cstdlib>
struct Bar
{
enum Group{ A , B , C };
};
struct Foo
{
template<typename T>
static void getSome( typename T::Group = T::A );
};
template<typename T>
void Foo::getSome( typename T::Group )
{
};
int main()
{
Foo::getSome<Bar>(); // Does not compile in VS 2008 & 2010 (compiles in gcc 4.5.3)
Foo::getSome<Bar>( Bar::C ); // Compiles in VS 2008 and gcc 4.5.3
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
错误信息
prog.cpp(11) : error C2589: '::' : illegal token on right side of '::'
prog.cpp(11) : error C2059: syntax error : '::'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
761 次 |
| 最近记录: |