mbo 0.15.0

MBO, a C++23 library

This C++23 library provides some general useful building blocks and integrates
with Google's Abseil library.

The library is tested with Clang (22+) and GCC (14+) on Ubuntu and MacOS (arm) using continuous integration: Test.

Library organization

The C++ library is organized in functional groups each residing in their own directory:

Installation and requirements

This repository requires a C++23 compiler (in case of macOS Xcode 15 is needed). This allows newer standard-library features to be used directly. Bazel 8 and newer remain supported.

The project only comes with a Bazel BUILD.bazel file and can be added to other Bazel projects.

The project is formatted with specific clang-format settings which require clang 16+ (in case of MacOs LLVM 16+ can be installed using brew). For simplicity in dev mode the project pulls the appropriate clang tools and can be compiled with those tools using bazel [build|test] --config=clang ....

Lint and format are driven by Trunk plus pre-commit. Devs are required to install both - curl https://get.trunk.io -fsSL | bash and pip install pre-commit (or your package manager's equivalent) - then run pre-commit install once. pre-commit is this repo's single git-hook entry point and delegates trunk fmt to trunk on every commit; trunk's own git-hook actions are deliberately disabled in .trunk/trunk.yaml so the two cannot fight over .git/hooks (a CI check fails the build if they are re-enabled). CI runs pre-commit, trunk check and clang-tidy as separate jobs and never auto-fixes; failing lint must be fixed locally and re-pushed.

clang-tidy is one of these pre-commit hooks as well - it moved there from trunk, which pinned a version too old to parse this code. It is opt-in for now (pre-commit run clang-tidy --all-files --hook-stage manual) and becomes automatic like the rest once the finding sweep lands. See STYLE_CPP.md for how to run it and how to build the compile_commands.json it needs.

MODULES.bazel

Check Releases for details. All that is needed is a bazel_dep instruction with the correct version.

bazel_dep(name = "mboworks_mbo", version = "0.15.0")

The Bazel-Central-Registry installation does not provide the LLVM tools and thus does not come with its own compiler - a restriction in how Bazel handles toolchains under bzlmod. To pull in the bundled toolchain, vendor bazelmod/llvm.MODULE.bazel as described in the release notes. Current versions are tested with GCC 14+ and Clang 22+ on Ubuntu and macOS. Other platforms and compilers are likely to work as well. However, Windows lacks some of the necessary tools and the library as well as its build system mostly assume Unix-style file and path names. That unfortunately means that on Windows some code cannot even be built.

Presentations

Practical Production-proven Constexpr API Elements

Presented at C++ On Sea 2024, this presentation covers the theory behind:

Slides are available at:




Practical Production Proven constexpr slides

Third-party components

The hash and digest libraries contain constexpr transcriptions of third-party
algorithms. The transcriptions are original code, but some closely follow
their reference implementations; the repository-root NOTICE file
reproduces the upstream notices, and the list below tracks exactly which
headers and Bazel rules make it apply. The project itself is Apache-2.0 (see
LICENSE).

NOTICE entries required for license compliance - for these algorithms the
licensed reference implementation effectively is the specification, and the
transcription follows its expression:

Header Bazel rule Upstream License
mbo/hash/hash_rapidhash.h //mbo/hash:hash_extra_cc rapidhash MIT
mbo/hash/hash_xxh64.h, mbo/hash/hash_xxh3.h //mbo/hash:hash_extra_cc xxHash BSD-2-Clause

NOTICE entries that are courtesy attribution only - public-domain/CC0
upstreams with no notice obligation, recorded for provenance (and to preempt
license-scanner findings of structural similarity):

Header Bazel rule Upstream License
mbo/hash/hash_murmur3.h //mbo/hash:hash_cc MurmurHash3 public domain
mbo/hash/hash_siphash.h //mbo/hash:hash_cc SipHash CC0 / public domain
mbo/hash/hash_fnv1a.h //mbo/hash:hash_cc FNV-1a public domain
mbo/digest/digest_blake3.h //mbo/digest:digest_cc BLAKE3 CC0-1.0 OR Apache-2.0 (CC0 elected)

Everything else is original MBO Works code. In particular, all algorithms
implemented from public standards carry no upstream code and need no notices:
SHA-1/SHA-2/SHA-3/SHAKE (FIPS 180-4 / FIPS 202), MD5 (RFC 1321), BLAKE2b
(RFC 7693), and HMAC (RFC 2104), and the default hash algorithms (the
in-house mumbo/jumbo family) are original code. Practical rule: only a
distribution that includes code from //mbo/hash:hash_extra_cc - directly or
transitively - must retain NOTICE; the default //mbo/hash:hash_cc
and //mbo/digest:digest_cc carry no compliance obligation (the digest
library's only NOTICE entry is courtesy).