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.
Year | C++ Standard[30] | Informal name |
---|---|---|
1998 | ISO/IEC 14882:1998[31] | C++98 |
2003 | ISO/IEC 14882:2003[32] | C++03 |
2011 | ISO/IEC 14882:2011[33] | C++11, C++0x |
2014 | ISO/IEC 14882:2014[34] | C++14, C++1y |
2017 | ISO/IEC 14882:2017[35] | C++17, C++1z |
2020 | ISO/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:
- C++ Concepts library
- 3-way comparisons
- Map contains
- Range-based for loop
- New identifiers ( import, module)
- Calendar and time zone library
- std::string functions
- Array bounded/unbounded
- std::to_array
- 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:
- Nested Namespaces
- Variable declaration in if and switch
- if constexpr statement
- Structured bindings
- Fold Expressions
- Direct list initialization of enums
C++ 14 key features:
C++14 includes the following new language features:
- binary literals
- generic lambda expressions
- lambda capture initializers
- return type deduction
- decltype(auto)
- relaxing constraints on constexpr functions
- variable templates
- [[deprecated]] attribute
C++14 includes the following new library features:
C++ 11 key features:
C++11 includes the following new language features:
- move semantics
- variadic templates
- rvalue references
- forwarding references
- initializer lists
- static assertions
- auto
- lambda expressions
- decltype
- type aliases
- nullptr
- strongly-typed enums
- attributes
- constexpr
- delegating constructors
- user-defined literals
- explicit virtual overrides
- final specifier
- default functions
- deleted functions
- range-based for loops
- special member functions for move semantics
- converting constructors
- explicit conversion functions
- inline-namespaces
- non-static data member initializers
- right angle brackets
- ref-qualified member functions
- trailing return types
- noexcept specifier
- char32_t and char16_t
- raw string literals
C++11 includes the following new library features:
- std::move
- std::forward
- std::thread
- std::to_string
- type traits
- smart pointers
- std::chrono
- tuples
- std::tie
- std::array
- unordered containers
- std::make_shared
- std::ref
- memory model
- std::async
- std::begin/end
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
Post a Comment