This syntax was used as a part of an answer to this question:
template <bool>
struct static_assert;
template <>
struct static_assert<true> {}; // only true is defined
#define STATIC_ASSERT(x) static_assert<(x)>()
I do not understand that syntax. How does it work?
Suppose I do
STATIC_ASSERT(true);
it gets converted to
static_assert<true>();
Now what?
indeed means
which evaluates to nothing.
static_assert<true>is just an empty structure without any members.static_assert<true>()creates an object of that structure and does not store it anywhere.This simply compiles and does nothing.
On the other hand
means
which results in compilation error.
static_asserthas no specialization forfalse. So a general form is used. But the general form is given as follows:which is just a declaration of a structure and not its definition. So
static_assert<false>()causes compilation error as it tries to make an object of a structure which is not defined.