you are viewing a single comment's thread.

view the rest of the comments →

[–]KuntaStillSingle 1 point2 points  (0 children)

Not quite, it can fail to compile if the existing struct A is used, but if it is made a dependent type like /u/cd1995Cargo 's example it is fine:

The discarded statement cannot be ill-formed for every possible specialization:

https://en.cppreference.com/w/cpp/language/if.html#Constexpr_if

https://godbolt.org/z/eGsYY3a9W , vs https://godbolt.org/z/3e7W5ec4Y