-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Feature suggestion: is_impl_all #26
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is possible to implement a macro that returns a const boolean that indicates if a type implements a certain trait. This might be useful to implement more complex static assertions when used together with
static_assertions::const_assert
. I took the macro's name from thestatic_assertions::assert_impl_all
macro and then change theassert
tois
since it takes the same arguments but returns a boolean instead of causing a compiler error.The macro I came up with looks like this:
Alternative macro implementation
I also made a different version of the macro that ensures that the
__static_assert__is_impl_all
lookup won't fail if a blanket trait is in scope that conflicts:Since the
__Wrapper
struct and the__AType
type alias can still cause name conflicts with the paths provided to the macro it doesn't really help that constants name can't cause name conflicts so this version of the macro isn't really better then the previous one and its definitely longer and more complex so it should probably not be used.Some Tests
Here is some tests I used to see if my macro worked:
The text was updated successfully, but these errors were encountered: