table of contents
std::basic_string_view::begin,std::basic_string_view::cbegin(3) | C++ Standard Libary | std::basic_string_view::begin,std::basic_string_view::cbegin(3) |
NAME¶
std::basic_string_view::begin,std::basic_string_view::cbegin - std::basic_string_view::begin,std::basic_string_view::cbegin
Synopsis¶
constexpr const_iterator begin() const noexcept; (since
C++17)
constexpr const_iterator cbegin() const noexcept; (since C++17)
Returns an iterator to the first character of the view.
range-begin-end.svg
Parameters¶
(none)
Return value¶
const_iterator to the first character.
Complexity¶
Constant.
Example¶
// Run this code
#include <concepts>
#include <string_view>
int main()
{
constexpr std::string_view str_view("abcd");
constexpr auto begin = str_view.begin();
constexpr auto cbegin = str_view.cbegin();
static_assert(
*begin == 'a' and
*cbegin == 'a' and
*begin == *cbegin and
begin == cbegin and
std::same_as<decltype(begin), decltype(cbegin)>);
}
See also¶
end returns an iterator to the end
cend (public member function)
begin returns an iterator to the beginning
cbegin (public member function of
std::basic_string<CharT,Traits,Allocator>)
(C++11)
2024.06.10 | http://cppreference.com |