Skip to main content

What is Boost?

Boost is a set of free, open-source, peer-reviewed C++ libraries that extend the standard library with facilities the language committee either hasn't standardised yet or never will. It is portable, header-heavy, and deliberately written to the same quality bar as std — to the point that Boost is the single largest source of future standard-library features.

Key characteristics

Standard-track: many components (shared_ptr, optional, variant, filesystem, thread) graduated into the ISO C++ standard. Mostly header-only: most libraries need no separate build step — just add the include path. Peer-reviewed: every library passes a formal community review before acceptance.

Why Boost exists

The C++ standard library is intentionally small and slow-moving. Boost fills the gap between "what the standard ships" and "what large C++ projects actually need": networking, parsing, graph algorithms, multiprecision arithmetic, serialization, and dozens of utilities. It acts as a staging ground — ideas are battle-tested in Boost for years before the committee considers standardising them.

This pipeline is why Boost and std feel so similar: std::shared_ptr, std::optional, std::filesystem, and std::thread are all descendants of Boost components. See Boost and the standard for the full lineage.

A library of libraries

"Boost" is not one library — it is ~160 independent libraries shipped together under one umbrella, one license, and one release cadence. They range from tiny header-only helpers to large subsystems:

ScaleExamplesWhat they are
Small utilitiesOptional, Any, lexical_cast, AssertDrop-in helpers, header-only
Mid-size librariesFilesystem, Program_options, Date_TimeFocused, sometimes compiled
Large subsystemsAsio, Spirit, Graph, SerializationWhole frameworks in themselves
Capitalisation convention

By convention library names are capitalised and prefixed in prose — Boost.Asio, Boost.Optional — but the code lives in lowercase headers (<boost/asio.hpp>) and the boost:: namespace (boost::optional).

A first taste

Most Boost libraries are header-only, so using one is just an include away:

optional_demo.cpp
#include <boost/optional.hpp>
#include <iostream>

boost::optional<int> parse_positive(int x) {
if (x > 0) return x; // engaged
return boost::none; // empty
}

int main() {
if (auto v = parse_positive(42)) {
std::cout << "got " << *v << "\n";
}
}
# Header-only: just point the compiler at the Boost include root
g++ -std=c++17 -I/usr/include optional_demo.cpp -o demo

No -lboost_optional is needed — there is no such library to link. The few libraries that do need linking (Filesystem, Thread, Program_options, ...) are covered in header-only vs compiled.

What Boost is good for

  • Filling standard-library gaps — networking (Asio), parsing (Spirit), graphs (BGL).
  • Getting future-standard features early — use boost::optional on a C++14 toolchain that lacks std::optional.
  • Heavy-duty utilities — multiprecision integers, dimensional analysis, lock-free queues.
  • PortabilityBoost.Config abstracts away compiler and platform differences.
Boost is not "free" to depend on

Boost is large. Pulling in even one library brings a sprawling web of internal headers, which inflates compile times and binary size. Prefer the standard equivalent when one exists and your toolchain supports it; reach for Boost when it genuinely adds something std lacks.

Where to go next