
Hello. I am trying to instantiate a template taking two parameters across a series of types contained in mpl::vector's, and place the resulting types in an mpl::vector. template <class A, class B> class T {}; typedef mpl::vector<int, double, char> Atypes; typedef mpl::vector<double, std::string> Btypes; template <template <class, class> class TEMPLATE, class ATYPE, class BTYPES, class CLASSES> struct unary_fold_inner : mpl::fold< BTYPES, CLASSES, mpl::push_back<mpl::_1, TEMPLATE<ATYPE, mpl::_2> >
{};
template <template <class, class> class TEMPLATE, class ATYPES, class BTYPES> struct unary_fold : mpl::fold< ATYPES, mpl::vector<>, typename detail::unary_fold_inner<TEMPLATE, mpl::_2, BTYPES, mpl::_1>::type
{};
typedef unary_fold< T, Atypes, Btypes
::type CLASSES;
I expect CLASSES will be an mpl::vector containing 2x3=6 types as follows: T<int, double> T<int, std::string> T<double, double> T<double, std::string> T<char, double> T<char, std::string> in other words, instantiating template T across all permutations of Atypes and Btypes. What I see instead is puzzling. Classes is indeed an mpl::vector, and indeed contains 6 types, but the types are simply: T<double, double> T<std::string, std::string> T<double, double> T<std::string, std::string> T<double, double> T<std::string, std::string> The iteration I'm trying to accomplish is all wrong. I think it has to do with how I'm creating my metafunctions. I'm still unclear about when the ::type suffix is needed (for the last parameter to mpl::fold<> for example) and whether I need an "apply" template somewhere in my struct's. Any help appreciated. v