B.5 — Introduction to C++23

What is C++23? In February of 2023, the ISO (International Organization for Standardization) approved a new version of C++, called C++23. New improvements in C++23 For your interest, here’s a list of the major changes that C++23 adds. Note that this list is not comprehensive, but rather intended to highlight …

16.5 — Returning std::vector, and an introduction to move semantics

When we need to pass a std::vector to a function, we pass it by (const) reference so that we do not make an expensive copy of the array data. Therefore, you will probably be surprised to find that it is okay to return a std::vector by value. Say whaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat? Copy …

5.5 — Constexpr variables

In the previous lesson , we defined what a constant expression is, as well as a compile-time constant. This lesson continues that discussion. When you declare a const variable using the const keyword, the compiler will implicitly keep track of whether it’s a runtime or compile-time constant. In most cases, …

11.4 — Deleting functions

In some cases, it is possible to write functions that don’t behave as desired when called with values of certain types. Consider the following example: #include <iostream> void printInt(int x) { std::cout << x << ‘\n’; } int main() { printInt(5); // okay: prints 5 printInt(‘a’); // prints 97 — …

15.10 — Ref qualifiers

Author’s note This is an optional lesson. We recommend having a light read-through to familiarize yourself with the material, but comprehensive understanding is not required to proceed with future lessons. In lesson , we discussed how calling access functions that return references to data members can be dangerous when the …