2

I stumbled upon this code without any explanation. Googling it is a nightmare, please explain what's this:

const std::vector<int> a<% 1,2,3 %>;
Pete Becker
  • 74,985
  • 8
  • 76
  • 165
Soup Endless
  • 439
  • 3
  • 10
  • This is wild :O – nick Oct 14 '22 at 09:54
  • c++ has never failed to suprise me – thedemons Oct 14 '22 at 09:58
  • 4
    No, those are not new C++ standard, but instead rather old C legacies. [Trigraphs](https://en.cppreference.com/w/cpp/language/operator_alternative) have been removed from C++17, as they can be very harmful, but *digraphs* are still accepted. Although for me, their only use is obfuscation. – prapin Oct 14 '22 at 10:35
  • 2
    Back in the olden days, some keyboards didn't have `{` and `}` keys. That made it hard to write C code. So C invented trigraphs and, later, digraphs, to make it possible for programmers with wimpy keyboards to write C code. `<%` is `{`, and `>%` is `}`. – Pete Becker Oct 14 '22 at 13:20
  • 1
    https://en.cppreference.com/w/cpp/language/operator_alternative – Jesper Juhl Oct 14 '22 at 13:28

0 Answers0