Tag: stdstring
-
Why is initializing a string to “” more efficient than the default constructor?
11 Generally, the default constructor should be the fastest way of making an empty container. That’s why I was surprised to see that it’s worse than initializing to an empty string literal: #include <string> std::string make_default() { return {}; } std::string make_empty() { return ""; } This compiles to: (clang 16, libc++) make_default(): mov rax,…