Skip to content

Blog

Make it a five-minute yes to contribute

Someone hits a small bug in your library and has a one-line fix they would happily send you. They want to help. Then they read your CONTRIBUTING.md: install Clang 18, CMake 3.28, Ninja, Conan 2.0, configure three presets, wait for a build. Twenty minutes later, before they have changed a single character, they give up. Willing contributors are rare, and that one was lost at setup.

Report from the Búzios 2026 ISO C++ Committee meeting

The Búzios 2026 ISO C++ Committee meeting in Brazil has just finished. C++26 failed its DIS ballot, so most of the week went to the national body comments, and many of them were about contracts. Quantities and units still got about a day in SG6 (Numerics). Below I describe what happened there, and I ask for your opinion on a change to the multiply syntax that two of my papers may force on the library.

Don't be asocial: respect the user's build system

You found the library, and now you just want to consume it. Except its CMake packaging is broken, or there is none at all, so using it means copying headers by hand, guessing at include paths, and fighting compiler flags it hardcoded over your own. There is no target to link against, and it drags in a home-grown dependency you have never heard of. To adopt it you would have to bend your build around its way of doing things, so you do what most people do: you reach for another library, or you write your own.

If they can't find you, the code doesn't matter

You need a units library for C++. You search GitHub for "units" and get a wall of repositories, all some variation of the same word, by different authors, with no obvious way to tell which one is alive, which one is serious, and which one will still be maintained next year. You pick one almost at random, or you give up and write your own. The library you needed might have been right there. You just could not find it, or could not tell it apart from the noise.

Introducing Photometric Conditions

A "1000 lm" LED lamp and a "1000 lm" low-pressure sodium lamp do not look equally bright at night. The number on both boxes is a photopic value: it weights the lamp's spectrum with \(V(\lambda)\), the spectral sensitivity of the eye's cone cells, which drive vision in daylight. At night, rod cells take over, the sensitivity curve shifts towards blue (\(V'(\lambda)\)), and the same two lamps deliver roughly 2000 and 250 scotopic lumens respectively. Both figures are luminous fluxes expressed in lumens, and a program that adds or compares them computes a result that is wrong by up to a factor of eight:

auto led = 1000. * lm;     // photopic value from the datasheet
auto sodium = 250. * lm;   // scotopic value from a night-visibility model
auto total = led + sodium; // compiles everywhere, means nothing

To the best of our knowledge, no units library catches this today, because every one of them (including mp-units until now) models a lumen as a lumen. This post introduces photometric conditions: a way to keep photopic, scotopic, mesopic, and custom quantities in separate quantity hierarchies, so that the mistake above breaks at compile time, while everything the physics does allow keeps working.

Measurement uncertainty and measured constants

When you write constexpr double G = 6.674e-11; in your code, the type says the value is exact, and it is not. The Newtonian constant of gravitation is one of the least precisely known constants in physics. CODATA 2018 lists it as 6.674 30(15) × 10⁻¹¹ m³ kg⁻¹ s⁻², and the (15) means the fifth significant digit is already uncertain. Only four digits of G are actually known. Every result derived from that double inherits an uncertainty that the program neither tracks nor reports, and nothing stops it from printing ten significant digits of a solar mass computed from a constant that guarantees four.

mp-units now has a way to model this. This post introduces the uncertain<T> representation type, the standard_uncertainty and relative_standard_uncertainty metadata for measured constants, and the measurement_of helper that connects them.