Half the memory for pointer-heavy C++

4-byte pointers and drop-in std containers for 64-bit C++, on the same trick as V8's pointer compression. Header-only, C++20, MIT.

Try it in your browser Start in two minutes Why it works GitHub
Bytes per element for 1,000,000 uint32_t: list 32.1 to 16.0, map 48.0 to 24.0, unordered_map 43.6 to 20.3
#include "cptr/all.hpp"

cptr::list<int> l;                          // was std::list<int>
cptr::ordered_map<int, int> m;              // was std::map<int, int>
cptr::unordered_map<int, int> h;            // was std::unordered_map<int, int>
cptr::ptr<node> n = cptr::make<node>();     // your own nodes: 4-byte pointers

Read more

WhyThe idea, what it buys, what it costs, and the alternatives. GuideHow it works, every header, allocators, persistence, rules. BenchmarksCompressed against raw pointers at p50 to p99.5; memory and latency for every container. API referenceEvery public type and function, with a start page and examples. Benchmark historyCompressed as % of raw pointers on every push to main. Code coverageLine and branch coverage of the headers from the tests.