std::experimental::basic_string_view<CharT,Traits>:: remove_suffix
From cppreference.net
<
cpp
|
experimental
|
basic string view
C++
Experimental
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
std::experimental::basic_string_view
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
constexpr
void
remove_suffix
(
size_type n
)
;
|
(库基础技术规范) | |
将视图的末尾向后移动 n 个字符。
如果 n > size ( ) ,则行为未定义。
目录 |
参数
| n | - | 要从视图末尾移除的字符数量 |
返回值
(无)
复杂度
常量。
示例
运行此代码
#include <experimental/string_view> #include <iostream> int main() { char arr[] = {'a', 'b', 'c', 'd', '\0', '\0', '\0'}; std::experimental::string_view v(arr, sizeof arr); auto trim_pos = v.find('\0'); if (trim_pos != v.npos) v.remove_suffix(v.size() - trim_pos); std::cout << "Array: '" << arr << "', size=" << sizeof arr << '\n' << "View : '" << v << "', size=" << v.size() << '\n'; }
输出:
Array: 'abcd', size=7 View : 'abcd', size=4
参见
|
通过将起始位置前移来缩小视图范围
(公开成员函数) |