2 ms·
The problem with const string& is that the resulting string is not interned - e.g. one copy in memory, which would later allow to save memory, compare by pointe
by malkia 16y ago
The problem with const string& is that the resulting string is not interned - e.g. one copy in memory, which would later allow to save memory, compare by pointer equality (eq), etc.
I understand that the language cannot express it, and that's why other languages (such as lua) do it the right way - immutable strings all the way, or at least by default (NSString)
- dzorz 16y agoYou can make a string class that interns strings. Language can express it, but std::string doesn't do it.