Thank you all for the replies. I see that there are workarounds, so no one feels eager enough to pursue a core language change. A regret, but probably acceptable, as the committee has a lot to do.

For the moment, I'll stick with the always_false<T> hack.

Best regards,

Yongwei

On Thu, 14 Jan 2021 at 03:27, Brian Bi via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
It was previously suggested (on the old list) to write a proposal to special-case static_assert: https://groups.google.com/a/isocpp.org/g/std-proposals/c/d2ADcbygYn4/m/jNtpL2GpBgAJ

There was support for this idea, but it seems no one ever got around to doing it.

On Wed, Jan 13, 2021 at 2:00 PM Andrew Schepler via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
A core language proposal to just make the original
static_assert(false, "msg") work as intended, only causing an error if
instantiated, would seem reasonable to me. I think it would just need
to call for a modification to the two rules in [temp.res.general]/6
which say that the program is ill-formed if no valid specialization
can exist or if instantiating a construct not depending on template
parameters would be ill-formed. As the one exception, a
static_assert-declaration appearing within a constexpr if substatement
is not considered ill-formed for these purposes if the
constant-expression is well-formed but its value is false. But if the
smallest enclosing constexpr if substatement is instantiated, that
does make the program ill-formed.

Often a narrow exception to a general rule is a bad idea and cause for
confusion, but this seems to be a common enough wanted use case to
consider it.


-- Andrew Schepler
--
Std-Discussion mailing list
Std-Discussion@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion


--
Brian Bi
--
Std-Discussion mailing list
Std-Discussion@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion


--
Yongwei Wu
URL: http://wyw.dcweb.cn/