Why is there no support for concatenating std::string and std::string_view?

后端 未结 1 759
無奈伤痛
無奈伤痛 2020-12-03 00:20

Since C++17, we have std::string_view, a light-weight view into a contiguous sequence of characters that avoids unnecessary copying of data. Instead of having a const

相关标签:
1条回答
  • 2020-12-03 01:08

    The reason for this is given in n3512 string_ref: a non-owning reference to a string, revision 2 by Jeffrey Yasskin:

    I also omitted operator+(basic_string, basic_string_ref) because LLVM returns a lightweight object from this overload and only performs the concatenation lazily. If we define this overload, we'll have a hard time introducing that lightweight concatenation later.

    It has been later suggested on the std-proposals mailing list to add these operator overloads to the standard.

    0 讨论(0)
提交回复
热议问题