Skip to content

Instantly share code, notes, and snippets.

@meetingcpp
Created March 18, 2018 14:42
Show Gist options
  • Save meetingcpp/a06e0ca694b57afb6271445a8d833722 to your computer and use it in GitHub Desktop.
Save meetingcpp/a06e0ca694b57afb6271445a8d833722 to your computer and use it in GitHub Desktop.
Get member names of a fusion adapted struct with mp11
template<class Seq>
constexpr std::array<const char*,boost::fusion::result_of::size<Seq>::value> get_member_names()
{
std::array<const char*,boost::fusion::result_of::size<Seq>::value> members{};
boost::mp11::mp_for_each< boost::mp11::mp_iota_c<boost::fusion::result_of::size<Seq>::value>>(
[&]( auto I ){
members[I]=boost::fusion::extension::struct_member_name<Seq,I>::call();
} );
return members;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment