Прескочи до съдържанието
Български

C++ 2017 May 2026

Type-safe union.

template<auto N> struct Foo ; Foo<42> f1; Foo<'c'> f2; 3.1 std::optional<T> A type-safe wrapper that may or may not hold a value. c++ 2017

Compile-time conditional compilation inside templates, discarding non-taken branches entirely. Type-safe union

if (auto it = m.find(key); it != m.end()) // use it here // it goes out of scope Permits defining variables in header files without violating the One Definition Rule (ODR). Essential for header-only libraries. if (auto it = m

std::any a = 42; int value = std::any_cast<int>(a); Non-owning reference to a string-like sequence. Ideal for function parameters.

Memory resources for container allocators, enabling custom memory management without recompiling container code. 3.8 std::clamp , std::gcd , std::lcm int x = std::clamp(5, 0, 10); // 5 int g = std::gcd(12, 18); // 6 3.9 Splicing for Maps and Sets Extract and insert nodes from associative containers without reallocation.

std::variant<int, float, std::string> v = "hello"; std::visit([](auto&& arg) std::cout << arg; , v); Type-erased container for any copyable type.