Why doesn't std::basic_string support concatenation through expression templates?

c++, expression-templates, qstring, std, string

Solution

Because nobody proposed it for the standard; unless someone proposes something, it doesn't get in. Also because it could break existing code (if they use `operator+` that is).

Also, expression templates don't work well in the presence of `auto`. Doing something as simple as `auto concat = str1 % str2;` can easily be broken. Hopefully, this is an issue that C++17 will resolve via some means.

Problem

Qt's `QString`s can be concatenated by `operator%` which uses expression templates to precalculate the resulting string's size and optimize several chained calls to `operator+`. See this question of mine for more info. Why hasn't `std::basic_string` adapted a similar construct? Is this even allowed per C++11? I see only advantages and clearly ABI compatibility can be broken by library implementors when they want to (and C++11 provided a good reason even for libstdc++).

Original source

Related problems