uj2*_*uj2 2 c++ gcc casting compiler-errors g++
我移植了一些C++代码GCC和apperantly当sapces都参与其中,为它是不愉快的C++风格铸造unsigned int(-1),long long(ShortVar)等等......它给出了一个error: expected primary-expression before 'long'.
有没有什么方法可以与海湾合作委员会达成和平,而不必越过其中的每一个并以c风格重写?
你想要static_cast<unsigned int>(-1)和亲属.那些往往被视为更多C++风格的演员表,并没有相同的问题.
对于它的价值,您必须这样做:
template <typename T>
struct identity
{
typedef T type;
};
Run Code Online (Sandbox Code Playgroud)
然后:
identity<unsigned int>::type(-1);
Run Code Online (Sandbox Code Playgroud)
或者在C++ 0x中:
template <typename T>
using id = T;
id<unsigned int>(-1);
Run Code Online (Sandbox Code Playgroud)