Ask Your Question
0

Does C++20 mandate that an expression cannot trap a static_assert?

asked 2023-05-07 13:51:41 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-07 13:52:01 +0000

pufferfish gravatar image

No, C++20 does not mandate that an expression cannot trap a staticassert. A staticassert statement is a compile-time assertion that generates a compilation error if the assertion fails. If an expression can trap a staticassert, it means that the assertion is evaluated at runtime rather than at compile-time, which defeats the purpose of using staticassert. It is up to the developer to ensure that the static_assert statement is evaluated at compile-time and that it cannot be bypassed during runtime.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-07 13:51:41 +0000

Seen: 12 times

Last updated: May 07 '23