What is std
beginner
c++11
c++14
c++17
c++20
c++23
Every three years the C++ standards committee releases a new C++ Standard specification.
Since 2011 the committee has released four C++ specifications: C++11, C++14, C++17, and C++20.
These standards define both features for C++ the language as well as features for the C++ Standard Library (STL), sometimes known as “std” for the namesake namespace it contains std
.
The std
namespace contains tons of useful classes, functions, and types.
A lot of well known data structures in computer science are made available only though the standard libary, not the core language itself.
Strings (std::string
), arrays that grow (std::vector
), hash maps (std::map
), sets (std::set
), optionals (std::optinal
), and lots more are found in the standard library.
It’s important to note that just because a new C++ Standard specification has been released that it does not mean your compiler, IDE, and other tools have been updated to take advantage of the new spec. Sometimes, compiler writers have been working on new features alongside the committee and have compatible features ready to go. Other times features take longer to make their way to compilers and therefore you and me, the end users. cppreference.com is a great resource to check for compiler support of C++ standards.
The C++ Standard and This Website
Generally, examples on this website use the second most recent C++ Standard. That means today most examples use C++17 because the most recent C++ Standard is C++20. In 2023, when C++23 is released, you will start seeing new examples using C++20 features and older examples being updated to take advantage of new features when it is appropriate. There’s two reasons for this:
- C++ has changed a lot over time. C++ examples written for C++11 (or even C++98) compatibilty look very different than examples written today. This isn’t very useful when all major compilers today support C++17.
- Speaking of compiler support, C++ compiler developers need time to implement the latest standards. It’s unlikely your compiler supports all the latest standard’s features. Writing code examples about a new standard isn’t very interesting when there’s no way to run them.
All that said, if major compilers do support a given feature and it’s of interest to the readers of this website, examples will be written demonstrating that feature (I’m looking at you std::format
). Pay close attention to the tags of each example (such as c++17
) for the standard of C++ the example uses.