Tuesday, October 10, 2017

C++17: Trigraphs Removed

C++17 removed trigraphs. Trigraphs are three-character sequences representing one character. They were a workaround for some keyboards not having cetain characters. Here is an example of trigraphs in C++98.

#include <iostream>

int main()
{
  std::cout << "??="  << " "; // #
  std::cout << "??//" << " "; // /
  std::cout << "??'"  << " "; // ^
  std::cout << "??)"  << " "; // ]
  std::cout << "??("  << " "; // [
  std::cout << "??!"  << " "; // |
  std::cout << "??<"  << " "; // {
  std::cout << "??>"  << " "; // }
  std::cout << "??-"  << " "; // ~

  std::cout << std::endl;
}
// Output: # / ^ ] [ | { } ~
References:
https://en.wikipedia.org/wiki/C%2B%2B17
https://stackoverflow.com/questions/1234582/purpose-of-trigraph-sequences-in-c

No comments:

Post a Comment