The C preprocessor does not recognize the syntax of the C ++ template, so the template brackets < and > not considered tokens by the preprocessor, they are treated as simple characters.
This means that the preprocessor will look at the comma between the template parameters as a macro parameter separator, for example:
assert( std::is_same<decltype(const_string), decltype(string_const)>::value);
To make the preprocessor see your expression as a single statement, simply add your assert parameter to an additional set of brackets:
assert((std::is_same<decltype(const_string), decltype(string_const)>::value));
static_assert does not have this limitation because it is a C ++ keyword , not a preprocessor macro like assert() . This means that it fully supports C ++ syntax and correctly sees template parameters.
source share