|
|
constexpr const_reference back()const; | (since C++17) | |
Returns reference to the last character in the view.
Ifempty() istrue, the behavior is undefined. | (until C++26) |
Ifempty() istrue:
| (since C++26) |
Contents |
data_
[size()-1]
Constant.
#include <iostream>#include <string_view> int main(){for(std::string_view str{"ABCDEF"};!str.empty(); str.remove_suffix(1))std::cout<< str.back()<<' '<< str<<'\n';}
Output:
F ABCDEFE ABCDED ABCDC ABCB ABA A
accesses the first character (public member function)[edit] | |
checks whether the view is empty (public member function)[edit] | |
(DR*) | accesses the last character (public member function of std::basic_string<CharT,Traits,Allocator> )[edit] |