Issue
Eclipse (Luna, 4.4.2) tells me that I have a syntax error on the following line:
static_cast<Vec<int, DIM>>(a.mul(b));
I remembered that double closing angle brackets >>
can lead to problems with some compilers, so I put a blank in between: > >
. The syntax error disappears.
However, I have many >>
in my program where no syntax error is detected, such as:
Node<Element<DIM>> * e= a.get();
Why do I get an error the above mentioned specific case? This is related to error: 'varName' was not declared in this scope, but I don't know why my compiler does accept a >>
sometimes, but not always.
Solution
You have used a pre c++11 standard compiler. The older standard had a problem letting the parser disambiguate a pair of closing angle brackets >>
used in a nested template type specifier, from the operator>>()
. Thus you had to write a space between them.
The samples like >>>
or >>*
are falling under a different case for the old parsers, thus they work without error message.
I have to admit, I don't actually know what exactly was done in the c++11 (the current) standards definitions, that this situation can be clearly disambiguated by a c++11 compliant parser.
Answered By - πάντα ῥεῖ
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.