Constexpr state potentially ill-formed for templated classes
Closed this issue · 7 comments
After implementing code following the constexpr-state trick guide from
https://woboq.com/blog/verdigris-implementation-tricks.html
I ran into https://bugs.llvm.org/show_bug.cgi?id=41785
However, as explained there, it's actually not a compiler bug but an ill-formed program. It seems to me that the "friend-trick" used in verdigris does not change this but just happens to work with compilers despite technically also being ill-formed code.
you might be right. :-/
However maybe the fact that the friend function has a a parameter of that class type might change that.
That said, i don't fully understand the issue, since the names should still refer to the same declarations while.
I don't see how the first parameter could change that given that it's the same for all function declarations :-(
Maybe using __COUNTER__
(or potentially BOOST_PP_COUNTER
for compilers that don't have __COUNTER__
, if they exist) might make it possible to handle the templated case?
Note that the version 1.2 of verdigris does not use exactly the method described in the blog post anymore. It uses __COUNTER__
do disambiguate, so maybe the problem is actually solved.
Oh, it already does! I had no idea.
I think this should be fine. W_STATE_APPEND
and W_STATE_APPEND_NS
do not refer to return types of member functions at all, so I think there's no way the problem is triggered.
So I believe this issue can be closed.
Thanks for the feedback.
Note that the version 1.2 of verdigris does not use exactly the method described in the blog post anymore. It uses
__COUNTER__
do disambiguate, so maybe the problem is actually solved.
but can you explain the new method a bit because the source code is hard to undersand, thanks.