Explicit instantiation of a mpl::vector of types

A

Aaron Graham

template <typename T> struct foo { ... };
typedef boost::mpl::vector<A, B, C, D, E, F> my_types;

I would like to explicitly instantiate foo<T> for all types in
my_types. Those are all the types that foo<T> will ever be used with,
and the surrounding metaprogramming is large and complex enough that I
don't want to put it all in a header file.

So I want to metaprogram the equivalent of:

template class foo<A>;
template class foo<B>;
template class foo<C>;
....etc...

The current solution I have is a function that calls mpl::for_each on
the vector of types, but that actually generates unnecessary code that
never needs to be called, which I find rather ugly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top