Skip to content

Posts

C++ Basics: Turn Cumulative Readings into Changes

Use std::adjacent_difference to calculate changes between successive cumulative measurements.

Read more →

November 6, 2026

C++ Basics: Sort Records by Multiple Keys

Use std::tie in a comparator to sort by one field and break ties with another.

Read more →

November 6, 2026

C++ Basics: Match Text Prefixes and Suffixes

Use starts_with and ends_with for literal text checks without manual substring arithmetic.

Read more →

November 6, 2026

C++ Basics: Initialize a Maximum for Negative Data

Use numeric_limits::lowest when a floating-point maximum accumulator must handle negative values.

Read more →

November 6, 2026

C++ Basics: Compute Starting Offsets from Batch Sizes

Use std::exclusive_scan to turn a list of lengths into starting offsets.

Read more →

November 6, 2026

C++ Basics: Compare Signed and Unsigned Integers Safely

Use std::cmp_less to compare integer values without converting a negative number to unsigned.

Read more →

November 6, 2026

C++ Basics: Check Whether a Value Is a Power of Two

Use std::has_single_bit for unsigned power-of-two checks, including the zero boundary.

Read more →

November 6, 2026

C++ Basics: Check Fixed-Array Access with at

Use std::array::at when an index should be checked and an out-of-range access handled explicitly.

Read more →

November 6, 2026

C++ Basics: Check an Integer Before Narrowing It

Use std::in_range to test whether an integer fits the destination type before casting.

Read more →

November 6, 2026

C++ Basics: Advance a Text View Without Copying

Use string_view::remove_prefix to consume a recognized label while leaving the original text intact.

Read more →

November 6, 2026