Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7521

General • Re: C++ std::string memory footprint

$
0
0
24 bytes is significant, imo. It could add up in struct's etc? Why not a separate string class, for short word strings? or a template where the user could set it?

Strange how they made this the default?

(That's why I don't like C++ nor the standard template library, it's all too complex for no reason or benefit.)
That was exactly my use case. I had a class with about 5 strings and needed like 8 of them in an array/vector and that was stupidly memory heavy to store just empty strings to start with.

I also feel there must have been a better way to evolve the standards for better string representation options. I really liked the way Symbian strings/descriptors worked for instance.
Thanks for sharing that video.
Memory representation have been hell in C++ for some time. The right thing to do was to optimize the string implementation in a new object rather than publish into the spec.
I'm not sure what was the right thing to do but I also feel like making the assumption that all systems running C++ can afford that sort of memory overhead for strings is a bit drastic.

Statistics: Posted by Slion — Wed Feb 12, 2025 11:26 am



Viewing all articles
Browse latest Browse all 7521

Trending Articles