c++ - g++ compilation error of another thing that works in msvs -
People, I'm posting some code from a project developed in MSVS to use GSAR. I have found very little difference, most of the things that allow MSVS but do not + G ++ are generally something that involves C ++ standards, things that give MSVS slides, but I There is a problem in seeing what is wrong in a particular section.
G ++ is having trouble matching operator to call! =, But seeing only a specific reference operator! = Works for a specific nested class if the hosting class is not a template, if I change the hosting class in class templates, everything breaks I'm losing something fundamental to either C ++ or G ++ I am doing something wrong.
I have not learned to cry "compiler bug"! Many times, so I want to see if anyone can see here what I am missing.
This work example is working, non-template version, and then broken, template version. G ++ - Gives Vision: G ++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
Working Reference Versions Without Templates
Namespace Works {Structure Host {Straight Iterator} {}; Iterator OP (); }; Bull Operator! = (Host :: Iterator Const & A, Host :: Iterator Const & A1); Bull F () {returns host (). Op ()! = Host () Op (); }} // namespace work
broken version with templates
Namespace Broken {template : Iterator Constant & A, Typnam Host T & gt; :: Iterator b & amp; a1;); Bool f () {Return Host & lt; Int & gt; (). Op ()! = Host & lt; Int & gt; (). Op (); }} Name Location Broken
The template version fails with errors:
main.cpp: 'bool broken :: f in the function ) ': Main.cpp: 50: Error:' Broken :: Host & lt; Int & gt; Operator! = ':: Host & lt; int & gt; () Broken :: Host & gt; T & gt; with Broken :: Host & lt; T & gt; :: op [T = int] ; :: op [with t = int] () '
This MSWC and GCC Neither works in.
The problem is that host : iterator
, T
in non-titular reference Since neither the parameter can be estimated to T
, the function template can not be institute.
This is the reason that you usually have cell Define overloaded operators.
The Straight Eratorator {Dude Bull Operator! = (Iterator Const & LHS, Iterator Const & RA) {Return False;}};
Comments
Post a Comment