My objective is to have a something like the following while writing the string "hello" as a regular string.
struct hello: element<hana::string<'h', 'e', 'l', 'l', 'o'>, std::int64_t>{};
I can have a function make a field of this type
template <typename ValueT, char... Cs>
element<boost::hana::string<Cs...>, ValueT> named_element(boost::hana::string<Cs...>&&, const ValueT& v = ValueT()){
return element<boost::hana::string<Cs...>, ValueT>(v);
}
// ...
auto hello_e = named_element<int>(BOOST_HANA_STRING("hello"));
But my objective is not to have an object of type element. Instead subclass from it.
I need something like the following, that I can wrap inside a macro.Then I'll use the type hello as template parameter.
struct hello: decltype(named_element<int>(BOOST_HANA_STRING("name"))){};
The above won't compile. But something similar would help.
I am using C++14
I've been looking into this, and the problem seems to be that
BOOST_HANA_STRINGcannot be used for a c++14constexpr. Luckily boost is quite amazing, so they've thought about that. Check the HANA string doc.I've managed to make a compiling example
godbolt