Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C++

Knowledge base — C++

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

Entries: 674

C++

C++ exception safety: basic, strong, and no-throw guarantees

The basic guarantee permits partial changes that leave valid state. The strong guarantee leaves no observable change on exception. The no-throw guarantee prevents exceptions from reaching the caller.

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

Feature flag and compile-time configuration

A compile-time flag selects a program variant when you build it. A runtime flag changes the behavior of an already-built program.

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

The `f` suffix on floating-point literals

Append `f` or `F` to make a floating-point literal a `float` rather than the default `double`. This affects type deduction and overload resolution.

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

The forwarding reference `F&&`

With `F` deduced, `F&&` can bind to either an lvalue or an rvalue. A direct call `f()` treats the callable as an lvalue; `std::forward<F>(f)` passes it on as an lvalue or rvalue according to the argument.

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

Heterogeneous lookup with a transparent comparator

Search an ordered associative container with a different type from its key, without constructing a temporary key. Learn why `std::less<>` enables the lookup overloads and why mixed comparisons must agree with the key order.

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

Implicit move from a return parameter

In C++23, `return a;` can move from a by-value parameter. This is not NRVO: the parameter is a separate object from the result.

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

Inline variable: one object across translation units

Define an inline variable with external linkage in a shared header to give multiple translation units the same object. Compare it with an ordinary namespace-scope `const` that gives each translation unit its own object.

Advanced · ISO C++23; implementation support may vary
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