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.
template<typename... Args> auto sum(Args... args) return (args + ...); // right fold
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
print("temporary"); // no allocation Most STL algorithms gained execution policy overloads: seq , par , par_unseq .
Allows declaring a variable scoped to the statement. if (auto it = m
// in a header inline int global_counter = 0; Mandates copy elision for prvalues, making certain moves/constructors unnecessary even conceptually.
std::variant<int, float, std::string> v = "hello"; std::visit([](auto&& arg) std::cout << arg; , v); Type-erased container for any copyable type. Args> auto sum(Args
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.