Explicit instantiation of a mpl::vector of types

Discussion in 'C++' started by Aaron Graham, Apr 3, 2009.

  1. Aaron Graham

    Aaron Graham Guest

    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.
    Aaron Graham, Apr 3, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    1,873
    Csaba
    Feb 18, 2006
  2. Replies:
    1
    Views:
    552
    Salt_Peter
    Dec 25, 2006
  3. Replies:
    3
    Views:
    269
    Markus Schoder
    May 28, 2007
  4. W. eWatson
    Replies:
    1
    Views:
    329
    W. eWatson
    Feb 9, 2010
  5. W. eWatson
    Replies:
    0
    Views:
    219
    W. eWatson
    Feb 16, 2010
Loading...

Share This Page