What Is The ‘>>’ Right-Angle Bracket Support In C++?

C++11 brings a lot of improvements over C++98. In C++98, two consecutive right-angle brackets (>>) give an error, and these constructions are treated according to the C++11 standard which means CLANG compilers no longer generate an error about right angle brackets. In this post, we explain this and how to solve the right-angle bracket problem in C++.

What is the right-angle bracket problem in C++?

Ever since the introduction of angle brackets in C++98, C++ developers have been surprised by the fact that two consecutive right-angle brackets must be separated by whitespace. For example, if you declare two-dimensional vector (int and bool) as below:

In C++98, the first declaration is OK, but the second declaration give errors because of ‘>>‘ (right angle brackets). However, both are OK in C++11 and above.

One of the problems was an immediate consequence of the “maximum munch” principle and the fact that >> is a valid token (right shift) in C++. In the CLANG-enhanced C++ compilers, two consecutive right-angle brackets no longer generate an error, and these constructions are treated according to the C++11 standard.

This issue was a minor issue in C++98, but persisting, annoying, and somewhat embarrassing problem. The cost was reasonable, and it seems therefore worthwhile to eliminate the surprise. C++98 developers needed to add space between them. If you want to get more information, you can see details here.

How can I solve the right-angle bracket problem in C++?

If you have C++98 compiler and come across the right-angle bracket problem, you need to add space between two ‘>’ right angle brackets. ‘>>’ should be written as ‘> >’ as shown in the example below.

Or you should change your C++ compiler so that it supports C++11 or above. C++17 is recommended. Note that the latest RAD Studio, C++ Builder standard and CLANG compilers supports C++17 features.

What is the right-angle bracket support in C++ 11?

In the Clang-enhanced C++ compilers, two consecutive right-angle brackets no longer generate an error, and these constructions are treated according to the C++11 standard.
This example below with ‘>>’ right angle brackets can be successfully compiled with any compiler that supports C++11 and above.

For more information, see the C++11 proposal document at Right Angle Brackets Proposal document

What Is The '>>’ Right-Angle Bracket Support In C++? C++ Builder logo” width=”128″ height=”128″ data-recalc-dims=”1″ data-src=”https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2022/01/CBuilder_11_512x512@1x-7286189-8695819.png?resize=128%2C128&ssl=1″ class=”wp-image-8129 lazyload” src=”data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==”></figure>
</div>
<p class=C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise version.