M
Marc Schellens
I posted a similar question some time ago, but didn't get an
satisfying answer.
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?
Or is it not possible?
Thanks,
marc
satisfying answer.
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?
Or is it not possible?
Thanks,
marc