This works in MSVC 2003, but not in g++ 4.1.2:
return unsigned long();
So I have to use the following:
{
typedef unsigned long ulong;
return ulong();
}
The errors are:
whatever.cpp:295: error: expected primary-expression before 'unsigned'
whatever.cpp:295: error: expected ';' before 'unsigned'
whatever.cpp:295: error: expected primary-expression before 'unsigned'
whatever.cpp:295: error: expected `;' before 'unsigned'
Both compilers are happy with returning int(), std::string(), etc.
(For the curious, I am forcing the default constructor because it's one of a set of specialised template functions, each of which returns the default value for a given type.)
Is this a bug in g++, or perhaps just a corner case that I was unaware of (and which MSVC handles 'better')?