没有为std :: string和std:string_view定义运算符'+'

时间:2017-12-21 15:20:03

标签: c++ c++17

是否有任何特殊原因导致operator+std::string未定义std::string_view?我觉得这很奇怪。

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std::literals;

int main()
{
    // That's OK
    std::cout << "Hello,"s + " World!" << std::endl;
    // Here at least GCC complains 
    std::cout << "Hello, "s + " World!"sv << std::endl;
}

0 个答案:

没有答案