Skip to content

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.

Read more →

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.

Read more →

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.

Read more →

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.

Read more →

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.

Read more →

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.

Read more →

November 2, 2026

C++ Basics: Define a Deterministic Priority Queue Order

Order queued jobs by urgency and break ties explicitly with a sequence number.

Read more →

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.

Read more →

November 2, 2026

C++ Basics: Compose Lazy Filter and Transform Views

Build a C++20 range pipeline without creating an intermediate result vector.

Read more →

November 2, 2026

C++ Basics: Choose the Accumulator Type Explicitly

Use the initial value to control numeric accumulation instead of accidentally truncating fractional values.

Read more →

November 2, 2026