C++ Reference ยท Preprocessor, Tools and Concepts
C++ standards: C++98 to C++26
A timeline of the ISO C++ standards from C++98 to C++26: what each added, how to select one with -std, how to detect it, and which version to use today.
C++ is standardized by ISO. Since 2011 a new version arrives about every three years, and each one adds language features, library components, and sometimes removes old ones. A compiler does not "have" a standard: it has a mode (-std=c++20) and an implementation status for each feature of that standard.
The standard is also not the same as the library. A standard library implementation (libstdc++, libc++, MSVC STL) decides when each header becomes available. Because of that, you should detect features, and not versions, when portability matters (see feature-test macros).
g++ -std=c++23 main.cpp # GCC / Clang cl /std:c++20 main.cpp # MSVC (also /std:c++latest)
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with std::cin or std::getline), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with std::cin or std::getline), it gets the next line from this box.
Timeline
| Standard | Year | Headline additions |
|---|---|---|
| C++98 / C++03 | 1998 / 2003 | First standard: classes, templates, exceptions, the STL (containers, iterators, algorithms), std::string, iostreams. C++03 was a bug-fix release. |
| C++11 | 2011 | The big modernization: auto, range-for, lambdas, move semantics and rvalue references, smart pointers, nullptr, constexpr, variadic templates, threads, <chrono>, <random>, <regex>, override/final, enum class, uniform initialization. |
| C++14 | 2014 | Polish: generic lambdas, return type deduction, make_unique, variable templates, relaxed constexpr, binary literals, digit separators. |
| C++17 | 2017 | std::optional, variant, string_view, filesystem, structured bindings, if constexpr, fold expressions, class template argument deduction, inline variables, parallel algorithms, guaranteed copy elision. |
| C++20 | 2020 | Concepts, ranges, coroutines, modules, the <=> operator, std::format, std::span, jthread, calendars and time zones, consteval, designated initializers. |
| C++23 | 2023 | std::print, std::expected, std::generator, explicit object parameters ("deducing this"), if consteval, flat_map, ranges::to, more range views, mdspan, move_only_function. |
| C++26 | 2026 | Static reflection, contracts, pack indexing, std::inplace_vector, std::execution, saturating arithmetic, #embed, a placeholder _ for unused names. |
C++23 is the latest published standard at the time of writing, with C++26 finalized by the committee but still being rolled out by compilers and libraries. See What is new in C++20, C++23 and C++26 for details.
Which standard should you use?
- New projects: C++20 or C++23. Both are well supported by current GCC, Clang and MSVC, and they remove a lot of boilerplate (concepts, ranges,
std::format). - Libraries that must build everywhere: pick the lowest version your supported compilers handle, commonly C++17, and gate newer features with feature-test macros.
- Legacy code: raise the standard one step at a time. The change from C++11 to 14 and 17 rarely breaks code; later steps may reveal ambiguities from new overloads or removed features.
- Embedded and safety-critical code often follows a fixed subset (for example MISRA C++ or AUTOSAR) based on C++14 or 17.
Usage notes
__cplusplusvalues are199711L,201103L,201402L,201703L,202002Land202302L. A C++26 draft mode reports a value above that (202400Lfor GCC 15-std=c++26).-std=c++23and-std=gnu++23differ. Thegnuflavor enables compiler extensions such astypeof, so use the plainc++form to keep code portable.- Deprecated and removed features. Examples:
auto_ptr(removed in C++17),register(C++17),std::random_shuffle(C++17), trigraphs (C++17), implicit capture ofthisthrough[=](deprecated in C++20),std::codecvt(deprecated in C++17). Use clang-tidy to find them. - C++ and C are different languages. A C program is not necessarily valid C++. See C and C++.
- Library features can lag.
<print>,<mdspan>,<stacktrace>and<generator>reached the major libraries at different times. Check the table at your compiler's documentation page. - Our runner uses
-std=c++23with GCC 15.2, so all live examples in this reference run in C++23 mode. C++26-only features are shown read-only.