boost variant over several possibilities

Viewed 417

Let's say I have a template class over one size a one type:

template<size_t N, typename T>
class C
{};

I want to generate a boost::variant which is capable of holding this class over several sizes and types, e.g. for sizes 1 and 2 and types int and unsigned int it will be

typedef boost::variant<
    C<1, int>, 
    C<1, unsigned int>, 
    C<2, int>, 
    C<2, unsigned int>
> my_variant;

The problem is that I need this setting in several places and each time with different sizes and types. Is there some template meta-programming magic to generate these variants from the list of possible values, something along the lines of

typedef generate_variant<C, 1, 2, int, unsigned int>::type my_variant;
1 Answers
Related