C++ Standards Documentation
Explore the evolution and specifications of the C++ programming language.
Key C++ Standards
-
C++98 (ISO/IEC 14882:1998)
The first official international standard for C++. Introduced templates, exceptions, RTTI, and the Standard Template Library (STL).
Published: 1998 -
C++03 (ISO/IEC 14882:2003)
A minor revision of C++98, focusing on defect reports and clarifications. No significant new features were added.
Published: 2003 -
C++11 (ISO/IEC 14882:2011)
A major revision, often referred to as the "modern C++" standard. Introduced smart pointers, `auto`, range-based for loops, move semantics, lambdas, and concurrency features.
Published: 2011 -
C++14 (ISO/IEC 14882:2014)
A smaller update building upon C++11, including generic lambdas, return type deduction for functions, and binary literals.
Published: 2014 -
C++17 (ISO/IEC 14882:2017)
Introduced parallel algorithms, structured bindings, `if constexpr`, filesystem library, and optional/variant types.
Published: 2017 -
C++20 (ISO/IEC 14882:2020)
A significant leap forward, adding concepts, modules, coroutines, ranges, and `std::format`.
Published: 2020 -
C++23 (ISO/IEC 14882:2023)
The latest standard, bringing features like `std::mdspan`, `std::print`, and improvements to ranges and concurrency.
Published: 2023
Understanding C++ Standards
The C++ standard is developed by the ISO/IEC JTC1/SC22/WG21 committee. It defines the syntax, semantics, and library for the C++ programming language. Each standard represents a snapshot of the language's evolution, incorporating new features, improvements, and bug fixes.
Why Standards Matter
Adhering to standards ensures portability and interoperability of C++ code across different compilers and platforms. They provide a stable foundation for developers and tool vendors, fostering a robust ecosystem.
Key Areas Covered
- Core Language Features (syntax, semantics, object-oriented programming, templates)
- Standard Library (containers, algorithms, I/O, strings, utilities, concurrency)
- Memory Management
- Error Handling (exceptions)
- Type System and Runtime Features
Resources and Links
Official standards are typically available for purchase from ISO and national standards bodies. However, many drafts and final publications are made accessible through academic or developer resources.
Example: C++20 Features
// C++20 Coroutine Example Snippet
#include
#include
struct task {
struct promise_type {
auto get_return_object() { return task{}; }
auto initial_suspend() { return std::suspend_always{}; }
auto final_suspend() noexcept { return std::suspend_always{}; }
void return_void() {}
void unhandled_exception() {}
};
};
task counter(int max) {
for (int i = 0; i < max; ++i) {
std::cout << i << std::endl;
co_await std::suspend_always{}; // Suspend and resume later
}
}
int main() {
counter(5); // This will suspend and print numbers
// Actual resumption logic would be needed in a full example
return 0;
}