The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Angle Bracket Placement


The first opening bracket after a template name is interpreted as part of the template's argument list, not as a greater-than operator. The first > after the opening angle bracket is interpreted as the end of the template's argument list, unless it is enclosed in parentheses, is part of a nested template, or is part of a template-style cast expression such as static_cast<int>.

Bad placement of angle brackets (<>) causes many template syntax errors. Make sure that you use proper spacing and parentheses to distinguish angle brackets from operators such as >, >> and ->. For example:

TempClass< float, a > b ? a : b > test1;

should be rewritten as:

TempClass< float, (a > b ? a : b) > test1;

Similarly, pay extra attention when using macros that use angle brackets as template arguments.

In Visual Studio 2013 and later (C++11), the compiler can distinguish the difference between the >> operator and adjacent closing angle brackets in a nested template argument. For example, this is now OK:

typedef std::vector<std::vector<bool>> Flags;