Posts
C++: Replace text without searching the replacement again
Advance past inserted text when replacing all non-overlapping occurrences of a literal string.
November 12, 2026
C++: Remove one occurrence from a multiset
Use an iterator to consume one duplicate value while keeping the remaining occurrences.
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.
November 12, 2026
C++: Keep a rolling total with a deque
Evict the oldest reading before appending to a fixed-length history window.
November 12, 2026
C++: Copy repeated regex matches into owned strings
Extract repeated ticket identifiers while keeping the regex and input alive during iteration.
November 12, 2026
C++: Choose ISO weekday numbers explicitly
Convert a validated calendar date to a weekday and distinguish Sunday-zero from ISO numbering.
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.
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.
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.
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.
November 11, 2026