std::experi...emove_suffix(3)
okay so bestie, welcome to the std::experi...emove_suffix(3) page from the C++ Standard Libary (yes, thatβs the manual name, typo and all ππ
). Itβs the std::experimental::basic_string_view::remove_suffix page, and weβre gonna get you fluent, no cap.
π NAME π
std::experimental::basic_string_view::remove_suffix - std::experimental::basic_string_view::remove_suffix
β¨ Synopsis β¨
constexpr void remove_suffix( size_type n ); (library fundamentals TS)
Moves the end of the view back by n characters.
β οΈ warning: the behavior is undefined if n > size().
π Parameters π
nβ number of characters to remove from the end of the view
πΈ Return value πΈ
(none) β thatβs it, bestie, there is literally no return value.
π¦ Complexity π¦
Constant. periodt. β¨
π Example π
Run this code π
// Run this code
#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';
}
π¨οΈ Output π¨οΈ
Array: 'abcd', size=7
View : 'abcd', size=4
π₯ See also π₯
remove_prefixβ shrinks the view by moving its start forward (public member function)
π Category π
Noindexed pages
xoxo, your Unix bestie π β this one came from source http://cppreference.com, dated 2024.06.10, and the footer title is std::experi...emove_suffix(3). slay. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms