std::string_view operator=
- 自 C++17 起
// Non const version only
constexpr basic_string_view& operator=( const basic_string_view& view ) noexcept = default;
用 `view` 的视图替换当前视图。
参数
- `view` - 要复制的视图
返回值
*this
复杂度
常数 - O(1)。
异常
(无)
示例
Main.cpp
#include <iostream>
#include <string_view>
int main()
{
std::string_view v = "Hello, world";
v = v.substr(7);
std::cout << v << '\n';
}
输出
world