std::basic_string_view<CharT,Traits>::front

Returns reference to the first character in the view. The behavior is undefined if empty() == true.

# Declarations

constexpr const_reference front() const;

(since C++17)

# Return value

Reference to the first character, equivalent to operator.

# Example

#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';
}

# See also