L
LRS Kumar
In Chapter 2 of MC++D, Andrei Alexandrescu introduces a macro called
STATIC_CAST. Here is the source related to it:
#ifndef STATIC_CHECK_INC_
#define STATIC_CHECK_INC_
namespace Loki
{
template<int> struct CompileTimeError;
template<> struct CompileTimeError<true> {};
}
#define STATIC_CHECK(expr, msg) \
{ Loki::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
#endif // STATIC_CHECK_INC_
I would be grateful if someone could explain to me the reason for the last line
of STATIC_CAST (the cast to void):
(void)ERROR_##msg;
STATIC_CAST seems to be doing its job even without this line. So why is it
needed?
Cheers,
LRS
STATIC_CAST. Here is the source related to it:
#ifndef STATIC_CHECK_INC_
#define STATIC_CHECK_INC_
namespace Loki
{
template<int> struct CompileTimeError;
template<> struct CompileTimeError<true> {};
}
#define STATIC_CHECK(expr, msg) \
{ Loki::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
#endif // STATIC_CHECK_INC_
I would be grateful if someone could explain to me the reason for the last line
of STATIC_CAST (the cast to void):
(void)ERROR_##msg;
STATIC_CAST seems to be doing its job even without this line. So why is it
needed?
Cheers,
LRS