c++ - Overloading operator<< to accept a template function -


I am trying to be able to write an extensible grammar using the function, but the correct syntax can not be found for this Accepting the template's function. I am using Visual C ++ 2008. This will accept a variable similar to the template function, or a similar non-templates function, but not just the template function.

Error 1 Error C2679: Binary '& lt; & Lt; & gt; : No operator was found which operates the right hand of the 'overloaded function' (or no acceptable conversion) (line *** )

 < Code> class grammar {friend grammar operator & lt; & Lt; (Const Grammer & LHS, Const Charl * Ras) {Return LHS; // Add rhs for grammar} template & lt; Typename T & gt; Friend grammar operator & lt; & Lt; (Cost Grammar & LHS, T (* RS) ()) {Return LHS; // duplication rhs () for grammar}}; Template & lt; Typename T & gt; Class expression page {}; Template & lt; Typename T & gt; ExpressionParticle & LT; T & gt; Expression (); ExpressionParticle & LT; Integer & gt; Expression (); Int _tmain (int argc, _TCHAR * argv []) {expression article & lt; Int & gt; (* P) ​​(); P = expression & lt; Int> Grammar () & lt; & Lt; "P"; Grammar () & lt; & Lt; P; Grammar () & lt; & Lt; ExpressionInt; Grammar () & lt; & Lt; The expression & lt; Integer & gt; // ***  

Expression & lt; Int & gt; What is the type of if it is not the type of top p? It is different from what type of ExpressionInt .

Your code looks okay, and G ++ is also fine with that of this Visual Studio The strange overload resolution bug in VS 2005 is the same problem is a possible solution (tested with VS 2005):

  template & lt; Class T & gt; T ID (tt) {return t; } Int main () {expression page & lt; Int & gt; (* P) ​​(); P = expression & lt; Int> Grammar () & lt; & Lt; "P"; Grammar () & lt; & Lt; P; Grammar () & lt; & Lt; ExpressionInt; Grammar () & lt; & Lt; ID (expression & lt; integer & gt;); // ***}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -