All about C++ standards

C++ is standardized by an ISO working group known as JTC1/SC22/WG21. So far, it has published six revisions of the C++ standard and is currently working on the next revision, C++23.

In 1998, the ISO working group standardized C++ for the first time as ISO/IEC 14882:1998, which is informally known as C++98. In 2003, it published a new version of the C++ standard called ISO/IEC 14882:2003, which fixed problems identified in C++98.

The next major revision of the standard was informally referred to as "C++0x", but it was not released until 2011. C++11 (14882:2011) included many additions to both the core language and the standard library.

In 2014, C++14 (also known as C++1y) was released as a small extension to C++11, featuring mainly bug fixes and small improvements.[37] The Draft International Standard ballot procedures completed in mid-August 2014.

After C++14, a major revision C++17, informally known as C++1z, was completed by the ISO C++ Committee in mid July 2017 and was approved and published in December 2017.

C++ standards
YearC++ Standard[30]Informal name
1998ISO/IEC 14882:1998[31]C++98
2003ISO/IEC 14882:2003[32]C++03
2011ISO/IEC 14882:2011[33]C++11, C++0x
2014ISO/IEC 14882:2014[34]C++14, C++1y
2017ISO/IEC 14882:2017[35]C++17, C++1z
2020ISO/IEC 14882:2020[13]C++20, C++2a


Key features of all standards till now:

C++ has a tradition of introducing new improvements and features in every 3 years in the form of a standard. With the last standard having released in 2020 as C++ 20, C++23 is going to be the latest standard. Below are some major features in C++ 20:

C++20 key features:

  1. C++ Concepts library
  2. 3-way comparisons
  3. Map contains
  4. Range-based for loop
  5. New identifiers ( import, module)
  6. Calendar and time zone library
  7. std::string functions
  8. Array bounded/unbounded
  9. std::to_array
  10. Likely and unlikely attributes

C++ 17 key features:

C++17 enables writing simple, clearer, and more expressive code. Some of the features introduced in C++17 are: 

  1. Nested Namespaces
  2. Variable declaration in if and switch
  3. if constexpr statement
  4. Structured bindings
  5. Fold Expressions
  6. Direct list initialization of enums

C++ 14 key features:

C++14 includes the following new language features:

C++14 includes the following new library features:


C++ 11 key features:

C++11 includes the following new language features:

C++11 includes the following new library features:


C++ 03 key features:

C++ 98 key features:


C++ code to check the standards version:

These are the C++ standards and what value you should be able to expect in `__cplusplus`:

  • C++ pre-C++98: __cplusplus is 1.
  • C++98: __cplusplus is 199711L.
  • C++98 + TR1: This reads as C++98 and there is no way to check that I know of.
  • C++11: __cplusplus is 201103L.
  • C++14: __cplusplus is 201402L.
  • C++17: __cplusplus is 201703L.
  • C++20: __cplusplus is 202002L.


#include<iostream>

int main() {
if (__cplusplus == 202002L) std::cout << "C++20\n";
else if (__cplusplus == 201703L) std::cout << "C++17\n";
else if (__cplusplus == 201402L) std::cout << "C++14\n";
else if (__cplusplus == 201103L) std::cout << "C++11\n";
else if (__cplusplus == 199711L) std::cout << "C++98\n";
else if (__cplusplus < 199711L) std::cout << "pre-standard C++\n";
return 0;
}

Comments

Popular posts from this blog

KMP Algorithm: Pattern Searching in Text

Z-Function Algorithm: Substring Search

Back of the envelope estimations