knatten / cppquiz

Source for the http://cppquiz.org website (not the questions)
GNU General Public License v3.0
98 stars 14 forks source link

Question 244 seems to have incorrect answer #322

Closed VishalSubramanyam closed 11 months ago

VishalSubramanyam commented 11 months ago

The following is taken from cppreference - static_assert

A static_assert declaration may appear at namespace and block scope (as a block declaration) and inside a class body (as a member declaration).

If bool-constexpr is well-formed and evaluates to true, or is evaluated in the context of a template definition and the template is uninstantiated, this declaration has no effect. Otherwise a compile-time error is issued, and the text of message, if any, is included in the diagnostic message.

So a compile-time error is expected.

tocic commented 11 months ago

Please see the explanation of the answer and this paragraph from the draft. Your link describes the behaviour of the static_assert declaration alone, but the issue here is in the usage of a class template with such a declaration.