Specialization Function Calls from other functions

I am trying to figure out to call a template specialization function from another. In the following short segment, I am trying to call the BLACK specific function from the RED. I get the following compiler error

cannot call member function ‘bool noClass<color>::_open() [with Colors color = (Colors)2]’ without object

which makes perfect sense. How can (or can I) make the call to the BLACK from RED work? The code segment is below from the noClass C++ header.


#ifndef COLORS_H
#define COLORS_H

enum class Colors { RED, GREEN, BLACK };

#endif /* COLORS_H */

#ifndef NOCLASS_H
#define NOCLASS_H


template <Colors color>
class noClass {
public: bool Open ( );
protected: bool _open ( );
};

template <Colors color> bool noClass<color>::Open ( ) { return noClass<color>::_open ( ); }

template <Colors color> bool noClass<color>::_open ( ) { return true; }

template <> inline bool noClass<Colors::BLACK>::_open ( ) { return true; }

template <> inline bool noClass<Colors::RED>::_open ( ) { return noClass<Colors::BLACK>::_open( ); }

#endif /* NOCLASS_H */
Topic archived. No new replies allowed.