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