I have boost fusion adapted structs like this one:
struct A {
int x;
double y;
std::string z;
};
BOOST_FUSION_ADAPT_STRUCT(
A,
x,
y,
z
)
I'd like to iterate over the types of the adaptation at compile time. E.g. if I have a class that wraps a type:
template <typename T> class Foo { ... };
then I'd like to be able to get type std::tuple<Foo<int>, Foo<double>, Foo<std::string>> given my struct A. I use std::tuple here just as an example; it can be another variadic type template class.
A c++17 solution would be welcome.
Helper for transforming adapted fusion struct to something like
std::tuple:Validation:
Helper which applies metafunction to each type in tuple:
Validation:
Also take a look at
Boost.MP11library. It hasmp_transformmetafunction which is equivalent toForEachfunction described above.