M
mschellens
I this question some time ago, but didn't get a satisfying answer.
(Like including a file several times. Practical but ugly.)
The problem:
Lets say I have a template and five integer and two floating
types.
template <typename T> class A
{
A() {}
~A() {}
public:
void B( T);
};
// for all int
template <typename T> void B( T)
{
// do something with int (char, unsigned int ...)
}
template<> void B( float)
{
// do something with float
}
template<> void B( double)
{
// do something with double where the code looks the same as for float
}
How to avoid to replicate the code for float and double?
Shouldn't there be something like:
template <> void B<T:[double,float]>( T)
{
// do something with float and double
}
or is there something alike already?
Regards,
Marc
(Like including a file several times. Practical but ugly.)
The problem:
Lets say I have a template and five integer and two floating
types.
template <typename T> class A
{
A() {}
~A() {}
public:
void B( T);
};
// for all int
template <typename T> void B( T)
{
// do something with int (char, unsigned int ...)
}
template<> void B( float)
{
// do something with float
}
template<> void B( double)
{
// do something with double where the code looks the same as for float
}
How to avoid to replicate the code for float and double?
Shouldn't there be something like:
template <> void B<T:[double,float]>( T)
{
// do something with float and double
}
or is there something alike already?
Regards,
Marc