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
105, newest first
Page
11 of 11
Written by
Sections
All eight
Feed
RSS
  1. 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

  2. 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.215 min readC++17

    written for C++17

  3. C++ try catch: how to throw and catch exceptions

    C++ try, catch and throw: the syntax, why you catch by const reference, the order of handlers, your own exception type, and what happens when nothing catches.

    Language §1.53 min readC++17

    written for C++17

  4. using namespace std: what it does and what to write instead

    What using namespace std does to name lookup, the clashes and silent overload changes it caused on four compilers, and what to write instead.

    Language §1.615 min readC++17

    written for C++17

  5. 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.314 min readC++20

    written for C++20