Loading lessons...
The Evolution of C++ (C++11 to C++23)
The Evolution of C++
C++ has grown through several official standards. Each new version adds features while keeping old code working, so code written for C++11 still compiles today.
The versions at a glance
- C++98 - the original standard: no
auto, nonullptr, manual memory everywhere. - C++11 - the big modernization:
auto, lambdas,nullptr, move semantics, smart pointers, fasterstd::vector. - C++14 - smaller: generic lambdas,
autoreturn types. - C++17 -
std::optional, structured bindings,if constexpr. - C++20 - concepts, ranges,
std::span, modules, the spaceship operator. - C++23 - polish:
std::expected,std::mdspan.
A concrete diff: old vs modern loop
std::vector<int> v = {1, 2, 3};
for (std::vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
std::cout << *it << " ";
}
That verbose iterator loop collapses in C++11:
std::vector<int> v = {1, 2, 3};
for (auto n : v) {
std::cout << n << " ";
}
The compiler fills in the type and the code reads like English.
Why modern matters
autoremoves repeated type noise.- Lambdas pass behavior inline instead of named helper functions.
std::vectorowns its memory, so the old manualdeletebugs disappear.- Smart pointers replace raw
new.
Picking a standard
You pick a standard with a compiler flag:
g++ -std=c++17 program.cpp -o program
cl /std:c++17 program.cpp
GCC and Clang use -std=: MSVC uses /std:. Use the newest standard your compiler supports.
TL;DR
- C++11 is the modern baseline:
auto, lambdas,nullptr, smart pointers. - C++17 adds structured bindings; C++20 adds ranges and concepts.
- Newer standards stay backward-compatible.
- Select a standard with
-std=or/std:.