这在VS2010sp1中没有编译(虽然它使用gcc 4.6进行编译):
template<class T>
struct Upcast;
template<>
struct Upcast<signed char>
{
typedef signed short type;
};
template<>
struct Upcast<char>
{
typedef typename std::conditional<std::is_signed<char>::value,short, unsigned short>::type type;
};
int main()
{
Upcast<char>::type a;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
来自VS的错误:
Error 1 error C2899: typename cannot be used outside a template declaration
Run Code Online (Sandbox Code Playgroud)
哪支队伍是对的?VS还是gcc?