Boost Users :
From: Christian Henning (chhenning_at_[hidden])
Date: 2006-08-22 23:38:20
> 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
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:
static const int num_channels = 3;
unsigned char red;
unsigned char green;
unsigned char blue;
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;
for( IMAGE::iterator it = image.begin()
; it != image.end()
; ++it )
Does that makes sense now?
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