Consider the following example
template<class Type = void> class MyClass
{
public:
double getValue()
{
// if "Type == void" return _x, if "Type != void" return _y
return (/* SOMETHING */) ? (_x) : (_y);
}
protected:
double _x;
static const double _y;
};
What could be the /* SOMETHING */ condition ?
I want to return _x if the template parameter is void, and return _y if not. How to do that ?
First off, you can’t return anything because the function return type is(fixed)void.Second, you can specialize that function to act differently when
Typeisvoid: