File indexing completed on 2025-01-30 09:35:26
0001 #ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
0002 #define BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/describe/detail/config.hpp>
0009
0010 #if defined(BOOST_DESCRIBE_CXX14)
0011
0012 #include <boost/describe/enumerators.hpp>
0013 #include <boost/mp11/algorithm.hpp>
0014
0015 #if defined(_MSC_VER) && _MSC_VER == 1900
0016 # pragma warning(push)
0017 # pragma warning(disable: 4100)
0018 #endif
0019
0020 namespace boost
0021 {
0022 namespace describe
0023 {
0024
0025 template<class E, class De = describe_enumerators<E>>
0026 char const * enum_to_string( E e, char const* def ) noexcept
0027 {
0028 char const * r = def;
0029
0030 mp11::mp_for_each<De>([&](auto D){
0031
0032 if( e == D.value ) r = D.name;
0033
0034 });
0035
0036 return r;
0037 }
0038
0039 }
0040 }
0041
0042 #if defined(_MSC_VER) && _MSC_VER == 1900
0043 # pragma warning(pop)
0044 #endif
0045
0046 #endif
0047
0048 #endif