I'm trying to be able to write an extensible grammar using functions, but can't seem to find the right syntax for accepting a template function. I'm using Visual C++ 2008. It will accept a variable of the same type as the template function, or a similar non-template function, but not the template function itself.
Error 1 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion) ( line
***
)
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 of Expression<int>
if it is not the type of p in above? How is its type different to the type of ExpressionInt
.