Will consteval allow using static_assert on function arguments?

Will consteval allow to use static_assert on function arguments? No. Function arguments have never been, and will continue to not be, usable as constant expressions. There is a difference between something being constant evaluated and being usable as a constant-expression. consteval ensures that we’re in a constant evaluation context, but it does not also cause … Read more

static_assert fails compilation even though template function is called nowhere

The standard says in [temp.res]/8 No diagnostic shall be issued for a template definition for which a valid specialization can be generated. If no valid specialization can be generated for a template definition, and that template is not instantiated, the template definition is ill-formed, no diagnostic required. … [ Note: If a template is instantiated, … Read more

Static assert in C

C11 standard adds the _Static_assert keyword. This is implemented since gcc-4.6: _Static_assert (0, “assert1”); /* { dg-error “static assertion failed: \”assert1\”” } */ The first slot needs to be an integral constant expression. The second slot is a constant string literal which can be long (_Static_assert(0, L”assertion of doom!”)). I should note that this is … Read more