查看: 135|回复: 1

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

[复制链接]

3

主题

3

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2022-9-23 21:29:29 | 显示全部楼层 |阅读模式
添加两个这样的函数,很难吗?
```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;
}
```
回复

使用道具 举报

3

主题

12

帖子

21

积分

新手上路

Rank: 1

积分
21
发表于 2025-3-8 08:54:01 | 显示全部楼层
好帖必须得顶起
回复

使用道具 举报

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

本版积分规则

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