Christian Henning wrote:
Not sure. Why not simply make IMAGE::color_t the key? Then give std::map a template key compare function templated by color_t; the template can be specialized for each color definition.
I suppose that would work, as well. But since I'm lazy ;-) and do not want to create a specialized template for each color defintion, I thought it might be cool to use some metaprogramming magic. Also, GIL is suppose to be extensible for users. Meaning they can define whatever color type they want. It would lessen their learning curve when there is a generic solution for all kinds of colors definitions.
Isn't the purpose of metaprogramming to avoid programming that can be done by the compiler? As I said all the information is available at compile time.
For example earlier in this thread there is a solution using boost::array. But this one is limited for homogeneous color types.
I think you mentioned earlier that there is a solution. I would like to know. It would be very educational to me to see what it's like.
Sure! It's interesting to note that Dan and I just recently wrote an article describing such a mapping from arbitrary structs to fusion sequences. The procedure requires a one-time mapping (a few lines of code) for each struct, and, afterwhich, you can use the mapping anywhere you want. In our example, serialization, in yours, histograms. The list is endless because the structs essentially become generic entities. This is such a common need that I am now thinking about ways to make it more seamless. I'll get back to you on this... Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net