Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 1285

Answer by HolyBlackCat for Why can I define a std::string instance that is constinit? Isn't constinit forbidden if an object requires dynamic initialization?

$
0
0

Common std::string implementations don't allocate on the heap if the string is short enough (this is called the "short string optimization" or "SSO").

Since the exact amount of characters that can fit into SSO (if any) depends on the implementation, you probably shouldn't rely on it, or should at least research how the big 3 standard libraries handle this.


Viewing all articles
Browse latest Browse all 1285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>