我使用g ++ 4.6.3(目前是ubuntu 12.04的默认包),标志为c ++ 0x,我偶然发现:
template <typename T>
inline T getValue(AnObject&)
{
static_assert(false , "this function has to be implemented for desired type");
}
Run Code Online (Sandbox Code Playgroud)
编译错误:
static_assertion failed "this function has to be implemented for the desired type"
Run Code Online (Sandbox Code Playgroud)
即使我还没有在任何地方调用此功能.
这是一个g ++错误吗?只有在代码中的某处调用此函数时,才应该实现此函数.