Answers

Newest first. When a later standard changes an answer, the article is updated in place and says what changed and since when.

Each answer names the standard it is written for: 111417202326

Document
Answers
Answers
24, newest first
Page
3 of 3
Written by
Sections
All eight
Feed
RSS
  1. std::thread and std::jthread: start, join and stop a thread

    Start a thread with std::thread or std::jthread (C++20): pass arguments with std::ref, get a result, stop it with a stop_token, and what a missed join prints.

    Concurrency §5.25 min readC++20

    written for C++20

  2. std::variant in C++: std::visit, std::get and the traps

    Create a std::variant, read it with std::get, get_if or std::visit, catch the missing case a conversion hides, and see what it costs and when to skip it.

    Standard Library §2.99 min readC++17

    written for C++17

  3. std::vector in C++: size, capacity, erase and reallocation

    std::vector size against capacity, how each standard library grows it, what every member invalidates, and erase, find and sort, checked on four compilers.

    Performance §4.212 min readC++17

    written for C++17

  4. When to mark a move constructor noexcept in C++

    Mark moves and swap noexcept when they cannot throw, or std::vector copies where it could move. What is noexcept already, and how to check it at compile time.

    Performance §4.312 min readC++20

    written for C++20