mp_map_find seems not working properly using g++
The code is at https://godbolt.org/z/KvjecnTe3. The code can be compiled if switching to clang 13.0.1, but gcc 11.2 or the trunk version fails. Interestingly, if I comment out line 22 and 23 as
// boost::mp11::mp_list<enum_<Foo::A1>, int>,
// boost::mp11::mp_list<enum_<Foo::A2>, double>,
then gcc can successfully compile the code. Any ideas?
Looks like a GCC bug. I'll try to figure out why it happens. Here's a workaround:
template <auto EnumVal> using enum_ = std::integral_constant<decltype(EnumVal), EnumVal>;
Interestingly, if I comment out line 22 and 23 as
Commenting out line 22 (Foo::A1) is enough. It looks like GCC doesn't take into account the type of EnumVal, just its value (which is 0 for both A1 and B1).
Thanks! this works for me. Just for your information, I tried similar code by using boost::mpl and it works (https://godbolt.org/z/zeGdoa3Te) for both gcc and clang.
Looks like a GCC bug. I'll try to figure out why it happens. Here's a workaround:
template <auto EnumVal> using enum_ = std::integral_constant<decltype(EnumVal), EnumVal>;
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104867