
Steven Watanabe wrote:
typedef make_features<mpl::vector<int, char, double> >::type f1; typedef make_features<mpl::vector<int, double> >::type f2; typedef make_features<mpl::vector<char> >::type f3; BOOST_MPL_ASSERT((boost::is_base_and_derived<f2, f1>)); BOOST_MPL_ASSERT((boost::is_base_and_derived<f3, f1>));
Sorry for taking so long to reply, but TMP always makes my head explode, and it takes a while to pick up the pieces and put them back together. In this case, I could have saved myself the explosion, because this interface offers behavior that is backwards from what I want. The conversion I want to allow is from fewer features to more, so I don't want f2 and f3 to be bases of f1, I want f1 to be a base for both f2 and f3. My current thinking is that this can't be done without knowing all possible features, so I'm thinking about an approach where I first define that: typedef mpl::vector< ... > AllPossibleFeatures; What I then want to define is template<typename MyFeatures> // sequence of features struct Features... subject to the following: typedef difference<AllFeatures, MyFeatures> TypesToAdd; // Features in // AllFeatures that // are not in // MyFeatures For each type T in TypesToAdd, Features<MyFeatures> virtually inherits from Features<insert<MyFeatures,T>::type>. So given typedef mpl::vector<int, char, double> AllPossibleFeatures; Features<mpl::vector<int>> (C++0x says I can omit the space between angle brackets :-}) would virtually inherit from Features<mpl::vector<int, char>> and Features<mpl::vector<int, double>. In turn, Features<mpl::vector<int, char>> and Features<mpl::vector<int, double>> would both virtually inherit from Features<mpl::vector<int, char, double>. I can write the difference metafunction above and I can write a rotate metafunction to help me iterate through all the types in the difference set. What I don't know is a good way to give Features<T> the appropriate number of virtual base classes. Can somebody help? Thanks, Scott