]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/describe/enum_to_string.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / describe / enum_to_string.hpp
1 #ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
2 #define BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED
3
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
7
8 #include <boost/describe/detail/config.hpp>
9
10 #if defined(BOOST_DESCRIBE_CXX14)
11
12 #include <boost/describe/enumerators.hpp>
13 #include <boost/mp11/algorithm.hpp>
14
15 namespace boost
16 {
17 namespace describe
18 {
19
20 template<class E, class De = describe_enumerators<E>>
21 char const * enum_to_string( E e, char const* def ) noexcept
22 {
23 char const * r = def;
24
25 mp11::mp_for_each<De>([&](auto D){
26
27 if( e == D.value ) r = D.name;
28
29 });
30
31 return r;
32 }
33
34 } // namespace describe
35 } // namespace boost
36
37 #endif // defined(BOOST_DESCRIBE_CXX14)
38
39 #endif // #ifndef BOOST_DESCRIBE_ENUM_TO_STRING_HPP_INCLUDED