Boost Users :
Subject: Re: [Boost-users] [MPL] Generate template instantiation ?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-10-06 14:42:43
Olivier Tournaire wrote:
> I have a class templated on 2 arguments, e.g. :
> template <typename PixelType , typename NbChannels> class myClass
> // ...
> This class is in a lib, and I would like to instantiate it for all
> base type (signed char, unsigned char, int, unsigned int ...), and for
> a given number of channels. For example :
> And so on. Is there a way to do this without writing all possiblities.
> Maybe with the MPL ?
Use the preprocessor.
#define MY_CLASS_INSTANTIATION(z, n, data) template class myClass<data, n>;
#define MY_CLASS_INNER_LOOP(r, data, T) BOOST_PP_REPEAT_FROM_TO(1, 10,
#define TYPES (unsigned char)(signed char)(int)(unsigned int)
BOOST_PP_SEQ_FOR_EACH(MY_CLASS_INNER_LOOP, ~, TYPES)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net