Modern C++ Features (C++11 through C++23)

Modern C++ features from C++11 to C++23: smart pointers, move semantics, lambdas, concepts, ranges, coroutines, and modules.

  • JSON6,104 B
  • YAML4,378 B · −28%
  • TOON3,528 B · −42%

Features added to C++ from C++11 through C++23, including smart pointers, move semantics, lambdas, auto, constexpr, structured bindings, concepts, ranges, coroutines and modules, each with its standard version, a description and an example.

Use it when

  • You are modernizing C++ code and need the standard that introduced a feature.
  • You need an example of a modern C++ idiom.

Watch out for

  • Compiler and standard-library support for newer standards varies; check your toolchain before relying on C++20 or C++23 features.
  • Modules and coroutines remain less widely deployed than the older features.

The data

Features

NameStandardDescriptionExample
Smart PointersC++11Automatic memory management: unique_ptr (exclusive ownership), shared_ptr (reference counting), weak_ptr (non-owning observer)auto ptr = std::make_unique<Foo>();
Move SemanticsC++11Transfer resources instead of copying: rvalue references (&&), std::move, move constructors/assignment operatorsstd::vector<int> v2 = std::move(v1);
Lambda ExpressionsC++11Anonymous functions with capture lists, mutable lambdas, generic lambdas (auto params in C++14)auto add = [capture](int x) { return x + offset; };
auto Type DeductionC++11Compiler deduces type from initializer expression, reduces verbosityauto it = map.find(key); auto [key, val] = *it;
constexprC++11/14/17Compile-time evaluation: C++11 (limited), C++14 (loops/branches), C++17 (if constexpr)constexpr int factorial(int n) { return n <= 1 ? 1 : n * factorial(n-1); }
Range-based forC++11Simplified iteration over containers and initializer listsfor (const auto& item : container) { /* ... */ }
Structured BindingsC++17Decompose tuples, pairs, and structs into named variablesauto [name, age] = getPerson();
std::optionalC++17Type-safe alternative to nullable pointers, represents optional valuesstd::optional<std::string> findUser(int id);
ConceptsC++20Named compile-time constraints on template parameters, better error messagestemplate<std::integral T> T add(T a, T b) { return a + b; }
RangesC++20Composable algorithms operating on ranges: views (lazy), actions (eager), pipe operatorauto evens = numbers | std::views::filter([](int n){ return n%2==0; }) | std::views::take(10);
CoroutinesC++20Functions that can suspend and resume: co_await, co_yield, co_returnGenerator<int> fib() { co_yield 0; co_yield 1; /* ... */ }
ModulesC++20Replace #include with import/export for faster compilation and better encapsulationimport std; export module mylib;

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
featuresnamestringSmart Pointers
featuresstandardstringC++11
featuresdescriptionstringAutomatic memory management: unique_ptr (exclus…
featuresexamplestringauto ptr = std::make_unique<Foo>();

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/cpp-modern-features?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/cpp-modern-features.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • cpp
  • c++
  • modern-cpp
  • smart-pointers
  • lambdas
  • concepts
  • ranges
  • coroutines

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets