-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for STATIC_CHECK
to test compile-time/constexpr expressions
#60
Comments
After thinking about this some more, I was toying with the idea that:
So essentially identical to Regardless, it turned out to be impossible. There does not seem to exist a generic way to obtain a boolean that is
or too limited (apply to functions only, and/or cannot use constexpr variables in the enclosing scope):
We will probably need to wait for reflection (that must be a meme by now) to be able to do this reliably. So in the end I'm sticking with the original plan:
Messages if the expression is not MSVC 19.33:
And perhaps that is the best way, because the compiler may be able to say exactly what wasn't |
I was also considering supporting expressions that evaluate to CONSTEXPR_CHECK(constexpr_vector{10}.clear()); to test that Anyway, perhaps the best way is to use another check macro Nothing is ever easy! I'll open a ticket for this and decide later. |
This has been requested on reddit.
Relevant bit of the discussion copied here:
Having reviewed this some more, Catch2 already defines
STATIC_CHECK
as juststatic_assert
, and they have a pre-processor value to convert that to a runtime check instead. But they won't ever run both the compile-time and run-time check at the same time. I think it would be confusing to have snitch do both, for this reason.I am thinking however that we could call it something new and different, like
CONSTEXPR_CHECK(expr)
, which would expand to something equivalent toand
CONSTEXPR_REQUIRE(expr)
would beThe text was updated successfully, but these errors were encountered: