S
stain
hi,
the following code produces an "illegal explicit template
specialization" warning. I have been fiddling around a while to find a
solution to specialize a template method of a specialized template
class. Here is what I would like to be able to call:
ChannelIndexTraits<RGB>::index<RED>() == 0
ChannelIndexTraits<RGB>::index<GREEN>() == 1
ChannelIndexTraits<RGB>::index<ALPHA>() == -1
ChannelIndexTraits<RGBA>::index<ALPHA>() == 3
ChannelIndexTraits<RGBA>::index<RED>() == 0
the following code produces the warning:
enum ColorComponents {
RGB,
RGBA
};
enum ChannelType {
ALPHA,
RED,
GREEN,
BLUE
};
template <ColorComponents>
struct ChannelIndexTraits {
template <ChannelType TYPE>
static int index() {return -1;}
};
// explicit template specializations to map channels to colorcomponents
template <>
static int ChannelIndexTraits<RGB>::index<RED>() {return 0;}
template <>
static int ChannelIndexTraits<RGB>::index<GREEN>() {return 1;}
template <>
static int ChannelIndexTraits<RGB>::index<BLUE>() {return 2;}
template <>
static int ChannelIndexTraits<RGBA>::index<RED>() {return 0;}
template <>
static int ChannelIndexTraits<RGBA>::index<GREEN>() {return 1;}
template <>
static int ChannelIndexTraits<RGBA>::index<BLUE>() {return 2;}
template <>
static int ChannelIndexTraits<RGBA>::index<ALPHA>() {return 3;}
Any Ideas?
the following code produces an "illegal explicit template
specialization" warning. I have been fiddling around a while to find a
solution to specialize a template method of a specialized template
class. Here is what I would like to be able to call:
ChannelIndexTraits<RGB>::index<RED>() == 0
ChannelIndexTraits<RGB>::index<GREEN>() == 1
ChannelIndexTraits<RGB>::index<ALPHA>() == -1
ChannelIndexTraits<RGBA>::index<ALPHA>() == 3
ChannelIndexTraits<RGBA>::index<RED>() == 0
the following code produces the warning:
enum ColorComponents {
RGB,
RGBA
};
enum ChannelType {
ALPHA,
RED,
GREEN,
BLUE
};
template <ColorComponents>
struct ChannelIndexTraits {
template <ChannelType TYPE>
static int index() {return -1;}
};
// explicit template specializations to map channels to colorcomponents
template <>
static int ChannelIndexTraits<RGB>::index<RED>() {return 0;}
template <>
static int ChannelIndexTraits<RGB>::index<GREEN>() {return 1;}
template <>
static int ChannelIndexTraits<RGB>::index<BLUE>() {return 2;}
template <>
static int ChannelIndexTraits<RGBA>::index<RED>() {return 0;}
template <>
static int ChannelIndexTraits<RGBA>::index<GREEN>() {return 1;}
template <>
static int ChannelIndexTraits<RGBA>::index<BLUE>() {return 2;}
template <>
static int ChannelIndexTraits<RGBA>::index<ALPHA>() {return 3;}
Any Ideas?