VinÃcius dos Santos Oliveira wrore:
Hi Peter,
could you consider using "compile-time strings" such as Hana's? I don't have much use for a const char* in TMP algorithms.
The descriptor strings are "compile-time". This, for instance, works. #include <boost/describe.hpp> #include <boost/mp11.hpp> #include <cstddef> #include <array> using namespace boost::describe; using namespace boost::mp11; enum E { v1 }; BOOST_DESCRIBE_ENUM(E, v1) constexpr std::size_t strlen_( char const * s ) { std::size_t n = 0; while( *s++ ) ++n; return n; } constexpr std::size_t hash_value( char const * s ) { std::size_t n = 5381; while( *s ) n = n * 31 + static_cast<unsigned char>( *s++ ); return n; } template<class D> constexpr auto name_as_array() { constexpr auto n = strlen_(D::name); std::array<char, n> r{}; for( std::size_t i = 0; i < n; ++i ) { r[i] = D::name[i]; } return r; } using D = mp_first< describe_enumerators<E> >; constexpr auto x1 = strlen_( D::name ); constexpr auto x2 = hash_value( D::name ); constexpr auto x3 = name_as_array<D>();