IE盒子

搜索
查看: 104|回复: 0

为什么c++标准库中的operator+没有string和string_view的重 …

[复制链接]

3

主题

5

帖子

11

积分

新手上路

Rank: 1

积分
11
发表于 2022-9-24 00:43:39 | 显示全部楼层 |阅读模式
添加两个这样的函数,很难吗?
```c++
template
inline constexpr std::basic_string operator+(
std::basic_string&& lhs,
std::basic_string_view rhs) {
lhs.append(rhs.begin(), rhs.end());
return lhs;
}

template
inline constexpr std::basic_string operator+(
std::basic_string_view lhs,
std::basic_string&& rhs) {
rhs.append(lhs.begin(), lhs.end());
return rhs;
}
```
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表