Skip to content

Posts

C++ Basics: Transfer Ownership with std::unique_ptr

Move a unique pointer into a function and observe the empty source without leaking or manually deleting memory.

Read more →

November 2, 2026

C++ Basics: Stop a std::jthread Cooperatively

Combine a stop-aware condition-variable wait with a readiness handshake and join before reading the result.

Read more →

November 2, 2026

C++ Basics: Separate Vector Capacity from Its Element Count

Observe how reserve allocates room while resize creates accessible vector elements.

Read more →

November 2, 2026

C++ Basics: Restore State with a Small Scope Guard

Use a noncopyable destructor-based guard to restore a flag even when an exception leaves the scope.

Read more →

November 2, 2026

C++ Basics: Represent Missing Results with std::optional

Return an optional result instead of reserving a valid integer as a missing-value sentinel.

Read more →

November 2, 2026

C++ Basics: Remove Matching Vector Elements with erase_if

Use the C++20 erase_if function to compact a vector and report how many elements were removed.

Read more →

November 2, 2026

C++ Basics: Reject Partial Integer Input with std::from_chars

Check both the conversion error and final pointer when parsing a complete integer field.

Read more →

November 2, 2026

C++ Basics: Preserve Equal-Key Order with stable_sort

Sort records by one key while retaining the input order of records with equivalent keys.

Read more →

November 2, 2026

C++ Basics: Pass Contiguous Data with std::span

Carry a sequence length alongside borrowed contiguous elements and validate subview bounds.

Read more →

November 2, 2026

C++ Basics: Observe Lifetime with std::weak_ptr

Lock a weak pointer before access and detect when the last shared owner has disappeared.

Read more →

November 2, 2026