Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 5788

C++

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.

Advanced · ISO C++23; implementation support may vary
C++

Integer literal suffix ULL

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.

Advanced · ISO C++23; implementation support may vary
C++

Iterator invalidation in C++: the std::vector case

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.

Advanced · ISO C++23; implementation support may vary
C++

Lambda capture by reference: `[&]`

`[&]` sets the by-reference capture default: the lambda uses the original local objects rather than copies, but it does not keep those objects alive.

Advanced · ISO C++23; implementation support may vary
C++

Lvalue reference declarator (&)

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.

Advanced · ISO C++23; implementation support may vary
C++

Lvalue reference (`R&`)

`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.

Advanced · ISO C++23; implementation support may vary
C++

Lvalue reference to an array: `(&items)[3]`

`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.

Advanced · ISO C++23; implementation support may vary
C++

Non-type template parameters

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.

Advanced · ISO C++23; implementation support may vary
C++

Object lifetime and strict aliasing

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.

Advanced · ISO C++23; implementation support may vary
C++

Literal operator declarations in C++

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.

Advanced · ISO C++23; implementation support may vary
C++

Output stream insertion operator (`<<`)

Use `<<` to write values to an output stream or change its formatting. The operand types distinguish stream insertion from the built-in left shift.

Advanced · ISO C++23; implementation support may vary
C++

Partitioned search range

`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.

Advanced · ISO C++23; implementation support may vary
C++

Placement new: construction in existing storage

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.

Advanced · ISO C++23; implementation support may vary
C++

Pointer declarator (*) in C++

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.

Advanced · ISO C++23; implementation support may vary
C++

Forming pointers to members in C++

`&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.

Advanced · ISO C++23; implementation support may vary
C++

Preconditions and domain invariants

Separate caller obligations from valid object state. Validate external input independently of `assert`, and design the type’s public interface to preserve its invariant.

Advanced · ISO C++23; implementation support may vary
C++

Direct construction of a prvalue result

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.

Advanced · ISO C++23; implementation support may vary
C++

Pure virtual function (= 0) in C++

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.

Advanced · ISO C++23; implementation support may vary
C++

Range adaptor pipe operator `|`

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.

Advanced · ISO C++23; implementation support may vary