[Bug c++/105351] [concepts] Constraint checking does correctly match static member attributes
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 3 14:00:47 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105351
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Gawain Bolton from comment #4)
> Finally, this also begs the question as to how one could write a requirement
> to ensure a class has a static attribute.
One way is to replace the requirement 'T::attr2' with 'typename
dummy<&T::attr2>' where 'dummy' is the class template
template<auto*> struct dummy;
This works because template arguments are constant expressions, and constant
expressions are evaluated even in unevaluated contexts, so the bullet point
that ensadc pointed out in comment #3 no longer applies.
This makes both Clang and GCC happy: https://godbolt.org/z/c8q355hfh
More information about the Gcc-bugs
mailing list