We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <boost/describe.hpp> #include <boost/mp11.hpp> #include <boost/hana.hpp> #include <cstdio> enum E { v1 = 11, v2, v3 = 5 }; BOOST_DESCRIBE_ENUM(E, v1, v2, v3) int main() { constexpr auto D = boost::mp11::mp_front< boost::describe::describe_enumerators<E> >(); std::printf( "%s: %d\n", D.name, D.value ); }
Is there a way to convert value of D.name to boost::hana::string? https://www.boost.org/doc/libs/1_79_0/libs/hana/doc/html/structboost_1_1hana_1_1string.html If not, is it planned to introduce a similar feature on the Boost Describe side?
D.name
boost::hana::string
The text was updated successfully, but these errors were encountered:
Like this:
namespace hana = boost::hana; template<class D, std::size_t... I> auto to_hana_string_impl( std::index_sequence<I...> ) { return hana::string_c< D::name[I]... >; } template<class D> auto to_hana_string() { return to_hana_string_impl<D>( std::make_index_sequence<__builtin_strlen(D::name)>() ); }
(https://godbolt.org/z/G5c51er4W)
It's a bit more complex than it needs to be, but see #10 for discussion why this is so.
Sorry, something went wrong.
Thanks for the detailed answer!
No branches or pull requests
Is there a way to convert value of
D.name
toboost::hana::string
?https://www.boost.org/doc/libs/1_79_0/libs/hana/doc/html/structboost_1_1hana_1_1string.html
If not, is it planned to introduce a similar feature on the Boost Describe side?
The text was updated successfully, but these errors were encountered: