-4

I don't know what is wrong with this compiling. I have tried every compiler and still they all show me an errors, and I don't understand what that error means.

Here is the error that I encounter:

image

I tried compiling with clang++, g++, and others, but did not seem to work.

What is the problem?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    I think we need to see more code, the problem is probably not on this line. This line by itself should compile see: https://onlinegdb.com/863D6YRzt. Did you include ?. Or you are using a compiler so old (ancient) it doesn't do templates well yet?. Side note : stop using `using namespace std;` – Pepijn Kramer May 12 '23 at 05:40
  • 1
    Can you please clarify what's unclear about this error? It tells you exactly what's wrong ("a space is required between consecutive right angle brackets") and it tells you exactly, even with example, what you should change ("use '> >'") - how could we give you more advice? – Lukas-T May 12 '23 at 05:44
  • 2
    Did you try adding a space as the error suggests? What C++ standard are you using? This is something that was fixed at some point but I don't remember when. – Retired Ninja May 12 '23 at 05:44
  • 1
    @RetiredNinja it was addressed in C++11 – Remy Lebeau May 12 '23 at 05:45
  • 1
    @RemyLebeau I thought that was it. Just took a little digging. :) [For nested templates, when did `>>` become standard C++ (instead of `> >`)?](https://stackoverflow.com/questions/7087033/for-nested-templates-when-did-become-standard-c-instead-of) – Retired Ninja May 12 '23 at 05:46
  • [How to Setup VS Code For C++ 14 /C ++17](https://stackoverflow.com/questions/55116344/how-to-setup-vs-code-for-c-14-c-17) – Jason May 12 '23 at 10:05
  • [How to enable C++17 support in VSCode C++ Extension](https://stackoverflow.com/questions/49397233/how-to-enable-c17-support-in-vscode-c-extension) – Jason May 12 '23 at 10:05

1 Answers1

1

It means you are not compiling your code using the C++11 or later standard.

Prior to C++11, >> is always parsed as a single token, ie operator>>, even when used in nested templates, so you must do what the error message says and put a space between adjacent > brackets when you are not trying to use operator>>, eg:

vector<vector<int> > vector_2d;
                  ^

Otherwise, update your compiler/project to ensure you are compiling for C++11 or later instead, where this is no longer an issue.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I used compiler C++17 or 23 , did not work either – Andrew Yang May 12 '23 at 06:55
  • Hi, I tried everything C++ 17, 23 and I used clang++ compiler. But it still not working. – Andrew Yang May 12 '23 at 07:04
  • Also, I tried to type space but VSC automatically changed back to no space. I don't know what to do. I am stuck. – Andrew Yang May 12 '23 at 07:05
  • @AndrewYang [How to Setup VS Code For C++ 14 /C ++17](https://stackoverflow.com/questions/55116344/how-to-setup-vs-code-for-c-14-c-17) – Jason May 12 '23 at 10:06
  • @AndrewYang [How to enable C++17 support in VSCode C++ Extension](https://stackoverflow.com/questions/49397233/how-to-enable-c17-support-in-vscode-c-extension) – Jason May 12 '23 at 10:06