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.

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;

Fetch the same bytes

The static files are identical to what the API returns, but with no rate limit and no server round trip. Use the API when you want a query and a content type; use the files when you want to cache one document.

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