#ifndef BOOST_DESCRIBE_ENUM_FROM_STRING_HPP_INCLUDED #define BOOST_DESCRIBE_ENUM_FROM_STRING_HPP_INCLUDED // Copyright 2020, 2021 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #if defined(BOOST_DESCRIBE_CXX14) #include #include #include #if defined(_MSC_VER) && _MSC_VER == 1900 # pragma warning(push) # pragma warning(disable: 4100) // unreferenced formal parameter #endif namespace boost { namespace describe { template> bool enum_from_string( char const* name, E& e ) noexcept { bool found = false; mp11::mp_for_each([&](auto D){ if( !found && std::strcmp( D.name, name ) == 0 ) { found = true; e = D.value; } }); return found; } } // namespace describe } // namespace boost #if defined(_MSC_VER) && _MSC_VER == 1900 # pragma warning(pop) #endif #endif // defined(BOOST_DESCRIBE_CXX14) #endif // #ifndef BOOST_DESCRIBE_ENUM_FROM_STRING_HPP_INCLUDED