Modern C++

Loading...
FreeFree topic, included on the free plan.
8 decks44 cards

About this topic

A problem-first tour of the C++ that arrived with C++11 and matured through C++17. Instead of reading about a feature, you implement the one function that makes it click — a move constructor, a forwarding factory, an RAII handle — and run it against a doctest suite in the browser. Where the point is a rule to recognise rather than code to write (what std::move really does, when a shared_ptr destroys its object), the card asks a multiple-choice question instead.

The topic moves through eight themed stages:

  1. Value Categories & References — lvalues, xvalues and prvalues; what a reference returns; how const& and && overloads pick by value category; what std::move is (a cast).
  2. Move Semantics in Action — writing move constructors and move assignment, the moved-from state, moving elements between containers, the three-move swap.
  3. Perfect Forwarding — forwarding references vs rvalue references, reference collapsing, std::forward in one-, two- and variadic-argument factories.
  4. RAII & Smart Pointers — acquire-in-constructor / release-in-destructor with a hand-written handle, then unique_ptr, shared_ptr counting, weak_ptr observation, and breaking ownership cycles.
  5. Literals & constexpr — the real type of a string literal, user-defined literals for units and byte sizes, and functions that run at compile time.
  6. Tuples & Vocabulary Typesstd::tuple and std::get, structured bindings, std::tie comparisons, plus std::optional, std::variant with std::visit, and std::string_view.
  7. Random & Time — engines vs distributions, std::shuffle, typed std::chrono durations, duration_cast, and timing work with steady_clock.
  8. Regular Expressionsregex_match, regex_search, capture groups, sregex_iterator, and regex_replace.

Exercises target GCC 14 in C++17 mode. Reference solutions are one click away, and each hint teaches the why — not just the call to make.

Decks