Neargye / magic_enum

Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
MIT License
4.88k stars 434 forks source link

Undefined behavior #315

Closed IvanArkhipov1999 closed 11 months ago

IvanArkhipov1999 commented 11 months ago

Hi there!

After adding magic_enum to my project I got unexpected build errors on some platforms in ci. But on some platforms build was successful.

I started looking into it and found out what was going on. In magic_enum std::get is extended https://github.com/Neargye/magic_enum/blob/master/include/magic_enum/magic_enum_containers.hpp#L1130. But с++ documentation states, that "It is undefined behavior to declare a full specialization of any standard library function template." (https://en.cppreference.com/w/cpp/language/extending_std section "Function templates and member functions of templates").

I suggest to define get for magic_enum in a separate namespace. Maybe you have other suggestions?

Neargye commented 11 months ago

Yes indeed, I think it’s worth leaving it in namespace magic_enum::containers