I get compile error with the former but latter works just fine.
error: ‘>>’ should be ‘> >’ within a nested template argument list
Thanks
I get compile error with the former but latter works just fine.
error: ‘>>’ should be ‘> >’ within a nested template argument list
Thanks
In the (now obsolete) revisions C++98 and C++03, the character sequence ">>" was unconditionally interpreted as the "right shift operator" token, so if you wanted to close multiple template argument lists, you would need to leave some intervening whitespace.
As of C++11, the lexical rules of the language have been modified to interpret ">>" as two consecutive template argument list ends, and the whitespace is no longer necessary. (However, this makes it necessary to parenthesize shift expressions in a template argument list.)
(In the same wash, C++11 also interprets <::foo
, when used as the first template argument, in the "obvious" way (beginning of argument list, followed by namespace qualifier) rather than consuming <:
as the alternative token for [
.)
Before C++11, you had to use whitespace to separate the angle brackets in nested templates - otherwise the compiler was interpreting it as right-shift operator ">>". In C++11, you can ommit the whitespace and it will be interpreted as brackets.
However some compilers (eg. MSVC++) ignore the standard and allow you to ommit the whitespace even when not using C++11 standard.