Possible Duplicate:
<: cannot begin a template argument list
Did you know that
int a<:10:>;
is equivalent to
int a[10];
?
I was writing some piece of code, where in I have a global namespace and a restricted namespace, say NS1 for now. I have a class called Module in my global namespace and I import some other libraries in NS1, which have a class called Module too. I was trying to create a std::list of my Module, i.e. ::Module inside a function in NS1 and doing so, I got this compilation error
std::list<::Module*> &myModule;
genllvm.cpp:60:11: error: ‘<::’ cannot begin a template-argument list
./genllvm.cpp:60:11: note: ‘<:’ is an alternate spelling for ‘[’. Insert whitespace between ‘<’ and ‘::’
./genllvm.cpp:60:11: note: (if you use ‘-fpermissive’ G++
What is the significance of this “<:” syntax?
Its call alternative tokens. C++ have several of them:
You can seen some of the alternative token consists of letters. So you can write
if (a<b and b<c)in a compiler which can correctly handle them. Their existence is for lack of symbols in keyboards or character sets. The alternative tokens are never replaced with the primary one (unlike trigraphs), but them behave the same as the primary one.However, C++0x require special treatment for
<::(2.5p3):So that
SomeTemplate<::SomeClass>can be correctly handled.