Get the latest tech news

Speculations on arenas and custom strings in C++


.com/blog/2024/04/14/ My techniques with arena allocation and strings are oriented around C. I’m always looking for a better way, and lately I’ve been experimenting with building them using C++ features.

They blow up compile times and code size, they’re noisy, and in practice they make debug builds (i.e.-O0) much slower (typically ~10x) because there’s no optimization to clean up the mess. The new string stuff is neat, but I hit a wall trying it out: These fancy constructors do not reliably construct at compile time, not even with a constexpr qualifier in two of the three major C++ implementations. Once a non-default constructor is defined, I’ve been unable to find an escape hatch back to the original, dumb, reliable behavior.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of C++

C++

Photo of Arenas

Arenas

Photo of Speculations

Speculations

Related news:

News photo

Is `(expession, lvalue) = rvalue` a valid assignment in C or C++?

News photo

Python, C++ inspired language that transpiles to C and can be embedded within C

News photo

Contracts for C++ (DbC) [pdf]