
AMDG Scott Meyers wrote:
I have a set of types representing features code might have, e.g.,
typedef mpl::vector
Features; These can occur in any combination as sets of features, e.g.,
tyepdef FeatureSet<ExceptionSafe> F1; typedef FeatureSet
F2; typedef FeatureSet F3; <snip> I'm looking for a way to automatically generate an inheritance hierarchy that will give me the behavior I've described. For the above example, the hierarchy has four levels. The root is all the features, because any subset of features is permitted to be implicitly convertible to the set of all features.
Root: FeatureSet
The leaves are the individual features:
Leaves: FeatureSet<ExceptionSafe> FeatureSet<ThreadSafe> FeatureSet<ReallyFast> FeatureSet<GPLed> <snip>
Is there some way for me to use the MPL to automatically generate the hierarchy I need?
Thanks,
Scott
There's nothing that works out of the box. Here's a quick hack:
#include ::type next;
typedef virtual_inherit {
typedef virtual_inheritmpl::empty_base type;
};
template<class S>
struct features :
virtual mpl::eval_if