C++C++11C++14C++17C++20

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

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

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.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?