1 #ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
2 #define BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
4 // Copyright 2020, 2021 Peter Dimov
5 // Distributed under the Boost Software License, Version 1.0.
6 // https://www.boost.org/LICENSE_1_0.txt
8 #include <boost/describe/detail/config.hpp>
10 #if defined(BOOST_DESCRIBE_CXX14)
12 #include <boost/describe/enumerators.hpp>
13 #include <boost/mp11/algorithm.hpp>
20 template<class E, class De = describe_enumerators<E>>
21 char const * enum_to_string( E e, char const* def ) noexcept
25 mp11::mp_for_each<De>([&](auto D){
27 if( e == D.value ) r = D.name;
34 } // namespace describe
37 #endif // defined(BOOST_DESCRIBE_CXX14)
39 #endif // #ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED