A
alex
I read famous book "Modern C++ Design". In chapter 2, there is a
STATIC_CHECK sample:
--------------------------------------------------
template < bool >
struct CompileTimeChecker
{
CompileTimeChecker(...);
};
template <>
struct CompileTimeChecker< false >
{};
#define STATIC_CHECK( expr, msg )\
{\
class ERROR_##msg{};\
( void )sizeof( CompileTimeChecker< ( expr ) >( ERROR_##msg() )
);\
}
---------------------------------------------------------
I use STATIC_CHECK, but get a error:
ISO C++ forbids applying `sizeof' to a function type
Why this error? Why use sizeof?
thanks!
STATIC_CHECK sample:
--------------------------------------------------
template < bool >
struct CompileTimeChecker
{
CompileTimeChecker(...);
};
template <>
struct CompileTimeChecker< false >
{};
#define STATIC_CHECK( expr, msg )\
{\
class ERROR_##msg{};\
( void )sizeof( CompileTimeChecker< ( expr ) >( ERROR_##msg() )
);\
}
---------------------------------------------------------
I use STATIC_CHECK, but get a error:
ISO C++ forbids applying `sizeof' to a function type
Why this error? Why use sizeof?
thanks!