I am trying to write extensible grammar using functions, but cannot find the correct syntax for accepting a template function. I use Visual C ++ 2008. It will accept a variable of the same type as a template function, or a similar function without a template, but not the template function itself.
Error 1 of error C2679: binary '<<: an operator was not found that accepts the right operand of the "overloaded function" type (or there is no acceptable conversion) (string ***)
class Grammar {
friend Grammar operator << ( const Grammar& lhs, const char* rhs ) {
return lhs; // append rhs to grammar
}
template<typename T>
friend Grammar operator << ( const Grammar& lhs, T (*rhs) () ) {
return lhs; // append rhs() to grammar
}
};
template<typename T>
class ExpressionParticle {
};
template<typename T>
ExpressionParticle<T> Expression () ;
ExpressionParticle<int> ExpressionInt ();
int _tmain ( int argc, _TCHAR *argv[] )
{
ExpressionParticle<int> (*p)();
p = Expression<int>;
Grammar() << "p";
Grammar() << p;
Grammar() << ExpressionInt;
Grammar() << Expression<int>; // ***
What is the type Expression<int>if it is not type p in the above? How its type differs from type ExpressionInt.