Sections[lang]
Language
The core language as it is written now, from values and moves to lambdas and modules, for developers who learned C++ once and need the current answer.
- Clause
- 1 of 8
- Answers
- 4, newest first
- Written for
- C++11, C++20
- Written by
- Miriam Castellanos
Much of what you write on every line has been reworked since C++03: how values are passed, moved and returned, what the compiler writes for a class, what auto deduces. This section covers those rules for the standard you compile with. Start with what std::move and && really do, then the special members C++ writes for you and when to write none of them. Since C++11 a throwing destructor calls std::terminate; can a C++ destructor throw covers what noexcept(false) changes.
In this section
- Value semantics and passing arguments
- Move semantics and rvalue references
- Copy elision and returning values
- Special member functions and the rule of zero
- Lambdas and closures
- Type deduction with
autoanddecltype const,constexprandconsteval- Exceptions,
noexceptand error handling - References, pointers and lifetimes
- Classes, inheritance and polymorphism
- Initialization rules
- Modules and headers
Answers in Language 4, newest first
Can a C++ destructor throw? What happens since C++11
Since C++11 a throwing destructor calls
std::terminate. Whatnoexcept(false)changes, why containers forbid it, and how to report failure fromclose().written for C++20
C++ virtual functions: override, pure virtual and the traps
How a C++ virtual function call is resolved, why to write override and a virtual destructor, pure virtual functions, and which warnings catch the traps.
written for C++11
C++ move semantics: what
std::moveand&&really doWhat a move is, why
std::movemoves nothing, what C++17, C++20 and C++23 changed about temporaries and returns, and four move mistakes clang-tidy catches.written for C++20
Rule of zero: the special members C++ writes for you
Which special member functions C++ declares for a class, what declaring one does to the others, and when to write none, all five, or delete them.
written for C++20