Skip to content

STL & Standard Library Implementation Deep Dive

This section provides in-depth analysis of open-source libraries directly related to the C++ standard library (STL) — not a simple API overview, but a dissection of design rationale, implementation details, comparisons with the standard library, and their influence on the evolution of the C++ standard.

Topic Orientation

These libraries are organized into three tiers:

  1. Standard Library Implementations: libc++ (LLVM), libstdc++ (GCC) — directly implement the C++ standard; understanding them means understanding how std::vector, std::string, std::format actually work under the hood
  2. Standard Predecessors & Supplements: Abseil, Folly, Boost, EASTL, fmt/spdlog, range-v3 — these libraries either inspired standard features (std::string_viewfolly::Range, std::format ← fmt), or provide high-performance alternatives where the standard library falls short
  3. Alternative STL Design: EASTL — challenges the design assumptions of the standard STL, redesigning containers and allocators for a specific domain (game engines)

Many modern C++ features drew inspiration from these libraries:

Standard FeatureOriginStandard Version
std::string_viewfolly::Range / absl::string_viewC++17
std::optionalboost::optional / folly::OptionalC++17
std::variantboost::variantC++17
std::filesystemboost::filesystemC++17
std::formatfmt libraryC++20
std::expectedabsl::StatusOrC++23
std::flat_map / std::flat_setBoost.Container flat_map / sorted-vector associative containers / P0429C++23
std::executionFolly Executor modelC++26
Rangesrange-v3C++20

Standard Library Implementations

libc++ (LLVM)

LLVM's C++ standard library implementation, known for its compact memory layout and the most up-to-date C++ standard support.

ChapterTopic
vector & stringThree-pointer vector, 24-byte SSO string, split_buffer, memcpy relocate
function & shared_ptr24-byte SBO function, single-allocation make_shared, control block layout
map/set & variantRed-black tree __tree, sentinel node, function pointer table visit
Ranges & unique_ptrPipe operator CRTP, filter_view caching, compressed_pair unique_ptr

libstdc++ (GCC)

GCC's C++ standard library implementation, the de facto standard in the Linux ecosystem, known for ABI stability.

ChapterTopic
string ABI MigrationCOW → SSO migration, dual ABI coexistence, __cxx11 namespace
vector & _HashtableVector growth policy, node-based _Hashtable for unordered_map
shared_ptr / RB-tree / functionControl block design, _Rb_tree sentinel, function pointer SBO

Standard Predecessors & High-Performance Alternatives

Abseil (Google)

The open-sourced version of Google's internal C++ codebase, following the "Live at Head" philosophy.

ChapterTopic
SwissTable Hash MapH1/H2 split, control byte layout, SSE2 probing, probe_seq, tombstone optimization, SOO
Status & StatusOrTagged union, RAII semantics, error propagation chain
Cord Large TextB-tree structure, external storage, zero-copy concatenation
Strings & Hash Utilitiesstring_view, StrCat, absl::Hash, SpreadingTree
Time & Basic UtilitiesTime zones, Duration, Span, optional

Folly (Meta)

Meta's C++ foundation library, the crystallization of Facebook's engineering practice.

ChapterTopic
fbstring Three-Tier StorageSmall/Medium/Large tiers, COW reference counting, page-crossing optimization
F14 Hash MapChunk-based layout, SIMD tag probing, comparison with SwissTable
IOBuf Zero-Copy BufferCircular linked list, reference counting, custom deallocation
Future/Promise AsyncCore shared state, state machine, SemiFuture, Executor
Synchronized & UtilitiesType-safe lock guard, Function SBO, ConcurrentHashMap

The oldest and most influential library collection in the C++ ecosystem. 170+ individual libraries, with the top 50 most popular analyzed and grouped by domain.

Overview & Navigation

EASTL (EA)

EA's redesigned STL alternative for game engines.

ChapterTopic
Allocator ModelNon-template instantiation, dual allocate overloads, dummy_allocator
fixed_* ContainersInline buffer, overflow mechanism, aligned_buffer
Intrusive Containers & Hash Tableintrusive_list, hashtable, red-black tree

fmt / spdlog

The reference implementation of std::format and a zero-configuration logging library.

ChapterTopic
fmt Formatting EngineCompile-time format string checking, type-erased tagged union, Dragonbox floating-point
fmt Advanced FeaturesCustom types, compile-time formatting, printf compatibility, ranges/chrono
spdlog ArchitectureLogger/Sink/Formatter three-layer design, async mode, log level filtering

range-v3

The predecessor of C++20 Ranges, Eric Niebler's masterpiece.

ChapterTopic
Pipe Operator MechanismCRTP base class, __pipeable, __compose, __bind_back
View Implementationfilter_view, transform_view, take_view, lazy evaluation
Actions & SentinelsEager operations, sentinel concept, iterator adaptation

Released under the MIT License