Skip to content

Posts

C++ Basics: Transfer a Range of Unique Owners

Move iterators let a vector range insertion transfer unique_ptr elements instead of trying to copy them.

Read more →

November 7, 2026

C++ Basics: Split Text on a Multi-Character Delimiter

Use a string_view delimiter with views::split to separate fields on an entire token and preserve empty fields.

Read more →

November 7, 2026

C++ Basics: Sort Records with a Member Projection

A ranges sort projection selects the field to compare while the algorithm moves whole records into order.

Read more →

November 7, 2026

C++ Basics: Round Negative Durations Deliberately

duration_cast truncates integral duration conversions toward zero.

Read more →

November 7, 2026

C++ Basics: Probe a Variant Without Throwing

Use std::get_if when one variant alternative is interesting and other alternatives should follow an ordinary fallback path.

Read more →

November 7, 2026

C++ Basics: Keep Range Search Results Attached to an Owner

A ranges search on a temporary vector returns a dangling marker instead of an iterator that would immediately outlive its storage.

Read more →

November 7, 2026

C++ Basics: Distinguish String Size from C-String Length

Growing a std::string with resize adds null characters by default.

Read more →

November 7, 2026

C++ Basics: Compute a Weighted Total with inner_product

Use inner_product to multiply corresponding quantities and prices, then add the products into a sufficiently wide total.

Read more →

November 7, 2026

C++ Basics: Call Members Through std::invoke

std::invoke applies a uniform calling interface to ordinary callables, member functions and member data.

Read more →

November 7, 2026

C++ Basics: Avoid Unnecessary Work in Optional Fallbacks

A fallback passed to value_or is evaluated even when an optional already contains a value.

Read more →

November 7, 2026