Creating a type vector depending on the template parameter, S, is certainly OK. I'll have to ignore the "bad pseudo code" though ;) You have to do it another way. Tell me precisely what you wish to do and I may be able to provide an example. Actually, I am compiling a small set of simple use-case examples. You wouldn't mind if I use our first example, would you?
No, of course not. How about a real life example? I trying to create a generic histogram operator for GIL ( Generic Image Library - see http://opensource.adobe.com/gil/index.html ). To create a histogram I need to count all colors of an image and put them into a map. Since there are many different color definitions, like rgb-8bit, cymk32, gray-8bit, etc., I was intend to create the key type of the histogram map as a tuple. For example: struct rgb8 { static const int num_channels = 3; unsigned char red; unsigned char green; unsigned char blue; }; struct cymk32 { static const int num_channels = 4; unsigned int cyan; unsigned int yellow; unsigned int magenta; unsigned int key; // black }; As you can see a color types can be defined very differently. Sometimes a color can even be a mixture of integer and floating point values, see HSV or HSL color space. Now imagine a function that takes any kind of image that's made of of a certain color space. By the way this is not GIL-comlaint code. I'm simplifying for the sake of understanding. template <class IMAGE> void create_histogram( const IMAGE& image ) { typedef IMAGE::color_t color_t; //somehow create type vector and subsequently a tuple containing //the color channel types typedef std::map< color_tuple, unsigned int > histogram_t; histogram_t histogram; for( IMAGE::iterator it = image.begin() ; it != image.end() ; ++it ) { ++histogram[*it]; } } Does that makes sense now? Christian