0
#include <string>
#include <string_view>

using namespace std::literals;

int main()
{
    "hello"s + "world";   // ok
    "hello"s + "world"sv; // error
}

See online demo

Why not make "hello"s + "world"sv valid in C++20?

xmllmx
  • 39,765
  • 26
  • 162
  • 323
  • Because C++20 has already been published, and new changes cannot be made anymore. – eerorika Sep 12 '21 at 12:29
  • `std::string_view` is of C++17, why did C++20 still not provide such an overloaded operator? Just an oversight? – xmllmx Sep 12 '21 at 12:31
  • Either 1. It was proposed and rejected or 2. It wasn't proposed. Read through the proposals to find out which it was. – eerorika Sep 12 '21 at 12:32
  • [Why is there no support for concatenating `std::string` and `std::string_view`?](https://stackoverflow.com/q/44636549/995714) – phuclv Sep 12 '21 at 15:31
  • The reasoning isn’t any different one language version later, even including the possibility that “no one got around to it yet”. – Davis Herring Sep 12 '21 at 16:45

0 Answers0