Posts
C++ Basics: Look Up Unordered Map Keys Without Inserting Them
Use find and end to report a missing key without changing an unordered map.
November 2, 2026
C++ Basics: Lock Two Related Counters with std::scoped_lock
Update two mutex-protected counters as one operation and verify a deterministic final total.
November 2, 2026
C++ Basics: Keep std::string_view Within Its Owner Lifetime
Compare a borrowed string view with an owning copy without creating a dangling reference.
November 2, 2026
C++ Basics: Insert Map Defaults Without Replacing Existing Values
Use try_emplace and its insertion flag to retain an existing map value.
November 2, 2026
C++ Basics: Handle Alternative Value Types with std::visit
Use a visitor with typed overloads to process each alternative in a std::variant.
November 2, 2026
C++ Basics: Find a Sorted Insertion Position with lower_bound
Locate the first element not less than a value and insert without breaking sorted order.
November 2, 2026
C++ Basics: Define a Deterministic Priority Queue Order
Order queued jobs by urgency and break ties explicitly with a sequence number.
November 2, 2026
C++ Basics: Convert Steady-Clock Durations Explicitly
Subtract time points from the same clock and choose integer or fractional duration units deliberately.
November 2, 2026
C++ Basics: Compose Lazy Filter and Transform Views
Build a C++20 range pipeline without creating an intermediate result vector.
November 2, 2026
C++ Basics: Choose the Accumulator Type Explicitly
Use the initial value to control numeric accumulation instead of accidentally truncating fractional values.
November 2, 2026