Speculations on arenas and custom strings in C++
nullprogram.com
nullprogram.com
"Some text"_s8
The underlying mechanism is even polite enough to supply a length without a horrible array template hack. (A somewhat unusual case where the C mechanism is a complete fail, the older C++ mechanism works but is incredibly ugly, and the newer C++ mechanism is actually straightforward and comprehensible.)Lost me there already.
> Its concepts regarding ownership and memory management are irreconcilable (move semantics, smart pointers, etc.), so I have to build from scratch anyway.
Absolutely not. The standard library has a zillion things, most pairs of which are independent and even unrelated. No type traits, no pairs and tuples, no std::arrays etc. - all things that are completely independent from memory management and ownership.
This provides the type being allocated to the operator new implementation.
If you want to experiment here’s the implementation: https://github.com/llvm/llvm-project/pull/113510
https://cppdepend.com/blog/understanding-small-string-optimi...
Since it doesn't own anything the Small String Optimisation is irrelevant.