Return a value depending of type

c++, c++11, templates, type-traits

Solution

First off, you can't return anything because the function return type is `void`.(fixed)

Second, you can specialize that function to act differently when `Type` is `void`:

template<class Type> class MyClass
{
    public:
        double getValue()
        {
            return _y;
        }
    protected:
        double _x;
        static const double _y;
}; 

template<>
inline double MyClass<void>::getValue()
{
   return _x;
}

Problem

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 ?

Original source