Skip to content

libc++ (LLVM) Source-Level Deep Analysis

Source path: references/impl/llvm-project/libcxx/include/

LLVM's C++ standard library implementation, known for its most compact memory layout and latest C++ standard support. Core design philosophy: minimal memory layout + trivially relocatable memcpy.

Table of Contents

ChapterContent
vector and stringThree-pointer vector, 24-byte SSO string (22 bytes inline), split_buffer, memcpy relocate
function and shared_ptr24-byte SBO function (vtable), make_shared single allocation
map/set and variantRed-black tree __tree, sentinel node __end_node_, variant visit function pointer table
Ranges and unique_ptrPipe operator CRTP, filter_view cache, compressed_pair unique_ptr

Three-Implementation Comparison

Componentlibc++ (LLVM)libstdc++ (GCC)MSVC STL
sizeof(string)243232
string SSO221515
vector growth~2×1.5×
vector relocatememcpymove+destroymove+destroy
unique_ptr8B8B8B
trivial_abisupportednot supportednot supported
function SBO24B (vtable)24B (function pointer)different
unordered_mapchainingnode-based _Hashtablechaining

Choose libc++ for: macOS/iOS/Android, most compact memory layout, trivially relocatable memcpy, latest C++ standard.

Released under the MIT License