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.
...
Here's how you can get a Hana string:
#include
#include
#include
#include <cstddef>
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;
}
template constexpr auto to_string_impl(
index_sequence )
{
return boost::hana::string_c;
}
template<class D> constexpr auto to_string()
{
return to_string_impl<D>( make_index_sequence() );
}
using D = mp_first< describe_enumerators<E> >;
constexpr auto st = to_string<D>();
#include <typeinfo>
#include <cstdio>
int main()
{
std::printf( "%s\n", typeid(st).name() );
}