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++

std::views::enumerate — iteration with an index

C++23 std::views::enumerate creates a lazy view that associates each range element with a zero-based index. It lets a loop access both the index and the element without maintaining a separate counter.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::filter — lazy range filtering

std::views::filter creates a lazy view of elements satisfying a predicate. It does not build a separate result container and preserves the order of selected elements.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::iota — a lazy sequence of successive values

std::views::iota creates a lazy view of values obtained by incrementing. The two-argument form excludes its end bound, while the one-argument form has no reachable end.

Basic · C++23 (repository compiler mode; displayed example verified by execution in an isolated environment)
C++

std::views::join — lazy range flattening

std::views::join creates a lazy view of elements from a range of ranges. It flattens one level, preserves order, and skips empty inner ranges without building a new container.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::keys — a view of first elements

std::views::keys creates a lazy view of the index-0 elements in a range of pairs or tuples. It lets you traverse map keys, but also works with other compatible ranges without creating a separate collection of keys.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::reverse — a range viewed in reverse order

std::views::reverse exposes a range's elements from last to first without rearranging the source. It requires a range that can be converted into a bidirectional view. If the view exposes mutable references, writing through them changes the original elements.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::slide — sliding window view

C++23 std::views::slide creates a lazy view of consecutive, overlapping windows of length n. The windows refer to elements in the underlying range rather than forming separate containers. It requires at least a forward_range and n > 0.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::split — split a range into subranges

std::views::split creates a view of parts separated by an element or pattern. Parts refer to the underlying data rather than becoming separate strings; adjacent and trailing delimiters can produce empty parts.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::take — a view of a range's first elements

std::views::take, declared in <ranges>, creates a view of at most count leading elements of a range. It preserves their order, does not create a separate container, and supports both direct calls and pipeline notation.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::views::take_while — a prefix satisfying a condition

std::views::take_while creates a lazy view of the initial range elements satisfying a predicate. It ends before the first element that fails the condition and does not resume searching for later matches.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::transform — lazy range transformation

std::views::transform creates a view that computes a function's result for an element only when that element is accessed. It does not create a result container; use it directly or in a pipeline with the | operator.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::values — a view of second elements

std::views::values creates a lazy view of index-1 elements from pairs or tuples. It lets you traverse map values or modify the second fields of pairs without creating a separate container.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::views::zip — iterate over ranges together

std::views::zip creates a lazy view of elements at corresponding positions in several ranges. Iteration stops at the shortest range, and reference access lets you modify mutable source elements.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::visit — invoke a callable for active alternatives

std::visit, declared in <variant>, invokes a callable with the active value from each supplied std::variant object. With no variants, std::visit(visitor) invokes visitor with no arguments if that invocation is valid. Alternatives are selected at runtime, but the invocation is checked at compile time for every combination of alternatives.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::void_t — detecting valid types

std::void_t from <type_traits> maps any valid pack of type arguments to void. Combined with SFINAE, it can detect whether a nested type is available without making the entire program ill-formed.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::weak_ptr — observation without extending object lifetime

std::weak_ptr<T> observes an object managed by std::shared_ptr without keeping it alive. Its lock() member obtains a temporary shared owner or an empty std::shared_ptr if ownership has already expired.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::wstring — a string of wchar_t elements

std::wstring is an alias for std::basic_string<wchar_t>, defined in <string>. It manages string storage and supports appending, comparison, and element access. It does not guarantee a portable Unicode encoding.

Basic · C++23; repository compiler flag, production runtime not attested
C++

ABI and PImpl: hiding implementation without promising full binary compatibility

PImpl moves a class's data into a hidden implementation object. It reduces header dependencies and helps preserve the public class layout, but does not guarantee ABI compatibility by itself. The key mechanics are an incomplete nested type and an out-of-line destructor.

Advanced · C++23; repository compiler flag, production runtime not attested
C++

Allocators and memory resources

An allocator determines how a container obtains and releases storage. std::pmr resources let you select allocation behavior at runtime without changing the container type, but require careful ordering of object lifetimes.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Program architecture: responsibilities and dependencies

Program architecture defines responsibilities, dependency direction, and object ownership. The example combines strategy pattern, factory registry, dependency injection, and decorator, while treating singleton as a separate decision about access and lifetime.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Asynchrony and concurrency

Asynchrony separates submitting work from obtaining its result. Concurrency lets tasks make progress over overlapping periods, but does not guarantee parallel execution. In C++, std::async and std::future support this separation with an explicit waiting point.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Class-specific allocation and deallocation operators

A class can define its own operator new and operator delete to control storage allocation and release. Overloads taking std::align_val_t handle alignment and must cooperate with the appropriate storage-release function.

Advanced · C++23; repository compiler flag, production runtime not attested
C++

Collections and containers

A collection is a general term for a group of elements. The C++ standard library provides containers with different storage and access rules: sequences, associative containers, and adaptors.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Comments and documentation

C++ provides // comments extending to the end of a line and /* ... */ block comments. They let you explain code and write documentation without executing their contents. Block comments cannot be nested.

Basic · C++23; repository compiler flag, production runtime not attested