Expand|Select|Wrap|Line Numbers
- template <class Key, int Value, class Tail>
- struct Parser<Typelist< MakePair<Key, Value>, Tail >, EmptyType>
- {
- static inline bool parse(int* value)
- {
- return (*value == Value) ? Key::Execute() : Parser<Tail>::parse(value);
- }
- };
This code compiles and runs correctly.
Now I want to make "Execute" template function that takes an int. I changed the definition of "Execute" to be template <int T> bool Execute()
and I changed the above code to be:
Expand|Select|Wrap|Line Numbers
- template <class Key, int Value, class Tail>
- struct Parser<Typelist< MakePair<Key, Value>, Tail >, EmptyType>
- {
- static inline bool parse(int* value)
- {
- return (*value == Value) ? Key::Execute<Value>() : Parser<Tail>::parse(value);
- }
- };
This won't compile and I get:
error: invalid operands of types `<unknown type>' and `int' to binary `operator<'
and
In static member function `static bool Parser<Typelist<MakePair<T, U>, Tail>, EmptyType>::parse(int*)':
classTemplates.h:81: error: expected primary-expression before ')' token
Why doesn't this work? Do I need to make the class "Key" a template class too? Everything that I've read says you can have a template member function in a class that is not a template class.
Why doesn't it recognize this as an attempt to pass a template parameter and try and treat it as a binary operator. How can I disambiguate this?