Integer promotions
Work out the type used for arithmetic on `std::uint8_t` and `std::uint16_t`, and distinguish it from the destination type and from how a value is printed.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Work out the type used for arithmetic on `std::uint8_t` and `std::uint16_t`, and distinguish it from the destination type and from how a value is printed.
The built-in suffix `ULL` gives a representable integer literal the type `unsigned long long`. It is not a literal operator or part of a number's sign.
Learn when a vector mutation invalidates iterators, references, and pointers, including the past-the-end iterator, and how to use a std::find_if result safely.
In `+hardPass`, unary `+` makes a non-generic captureless lambda use its implicit conversion to a function pointer. Changing the argument type can change which overload is selected.
`score =+ delta` assigns the result of unary `+delta`. To add `delta` to the current value of `score` and store the result, use `score += delta`.
Declare names for tuple elements with structured bindings. Learn when they refer to a copy or the original, and how they differ from `std::get` and `std::tie`.
`[&]` sets the by-reference capture default: the lambda uses the original local objects rather than copies, but it does not keep those objects alive.
A declarator’s `&` forms an lvalue reference type. Learn what it can bind to, when you can write through it, and how to avoid dangling references.
`R&` aliases an existing object. Assigning through it modifies that object, and returning `R&` lets the caller keep referring to the same object without making a copy.
`int* (&items)[3]` refers to the entire array of three pointers. The bound stays part of the type, and a cleanup guard can update the original pointer slots.
`= delete` forbids use of a specific function or constructor without removing it from the overload set. It does not destroy an object or release memory.
A non-type template parameter takes a value rather than a type. See how `std::size_t Size` fixes an array’s extent and how the compiler deduces it from function arguments.
Storage can outlast the object it holds. Lifetime determines when an object exists, while strict aliasing determines which expression types may access its stored value.
A pool reuses individual slots; a monotonic arena reclaims storage in bulk. A generation-tagged handle distinguishes a new object from an old one at the same address.
Declare custom suffixes `_KiB`, `_MiB`, and `_pct`. See how the literal's form selects an operator and how built-in `ULL` and unary minus differ from a custom suffix.
Use `<<` to write values to an output stream or change its formatting. The operand types distinguish stream insertion from the built-in left shift.
`std::lower_bound` does not need a fully sorted range: for the given key, all elements that pass its test must come before all elements that fail it.
Construct an object in a prepared slot, manage its lifetime separately from the storage, and make the slot owner explicitly non-copyable and non-movable.
Learn how ISO C++23 uses `*` to declare pointers, where to put `const`, and how to distinguish a pointer to an array from an array of pointers.
`&C::m` can identify a non-static member without choosing an object. Apply the resulting member pointer to an object or use it as a projection in a ranges algorithm.
Separate caller obligations from valid object state. Validate external input independently of `assert`, and design the type’s public interface to preserve its invariant.
Since C++17, a same-type class prvalue constructs the result directly, without copying or moving the whole object. NRVO is optional, and member initialization can still copy data.
Use `= 0` to declare a pure virtual member function and define an abstract interface. Calls through that interface can select different implementations based on the object's type.
Use `|` to apply an adaptor closure to a range or compose two closures into a reusable pipeline. This overload is distinct from built-in bitwise OR.