Skip to content

Posts

C++: Replace text without searching the replacement again

Advance past inserted text when replacing all non-overlapping occurrences of a literal string.

Read more →

November 12, 2026

C++: Remove one occurrence from a multiset

Use an iterator to consume one duplicate value while keeping the remaining occurrences.

Read more →

November 12, 2026

C++: Read a required map key without inserting it

Use map at when a missing key should raise an exception and leave the map unchanged.

Read more →

November 12, 2026

C++: Keep a rolling total with a deque

Evict the oldest reading before appending to a fixed-length history window.

Read more →

November 12, 2026

C++: Copy repeated regex matches into owned strings

Extract repeated ticket identifiers while keeping the regex and input alive during iteration.

Read more →

November 12, 2026

C++: Choose ISO weekday numbers explicitly

Convert a validated calendar date to a weekday and distinguish Sunday-zero from ISO numbering.

Read more →

November 12, 2026

C++: Check a bit position with bitset test

Use bitset test for bounds-checked access and handle an index equal to the bit count.

Read more →

November 12, 2026

C++: Remove list entries while retaining a surviving reference

Use list remove_if and its C++20 removal count without invalidating references to retained elements.

Read more →

November 11, 2026

C++: Reject trailing input in a stream record

Read two integers with an istringstream and reject extra tokens while accepting trailing whitespace.

Read more →

November 11, 2026

C++: Preserve a trailing empty field with getline

Split a simple comma-delimited record without losing the empty field after a final comma.

Read more →

November 11, 2026