constexpr if and static_assert

This is talking about a well-established rule for templates – the same rule that allows compilers to diagnose template<class> void f() { return 1; }. [temp.res]/8 with the new change bolded:

The program is ill-formed, no diagnostic required, if:

  • no valid specialization can be generated for a template or a substatement
    of a constexpr if statement ([stmt.if]) within a
    template
    and the template is not instantiated, or
  • […]

No valid specialization can be generated for a template containing static_assert whose condition is nondependent and evaluates to false, so the program is ill-formed NDR.

static_asserts with a dependent condition that can evaluate to true for at least one type are not affected.

Leave a Comment