std::basic_...iew::cbegin(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

Okay bestie, this is the std::basic_...iew::cbegin(3) page from the C++ Standard Libary β€” yes, β€œLibary,” we are keeping that exactly as the manual name says, no autocorrect erasure πŸ’….

The entry is: std::basic_string_view::begin,std::basic_string_view::cbegin β€” and the description is literally the same string again: std::basic_string_view::begin,std::basic_string_view::cbegin. Iconic repetition, no notes ✨.


✨ Synopsis ✨

constexpr const_iterator begin() const noexcept;   (since C++17)
constexpr const_iterator cbegin() const noexcept;  (since C++17)

It returns an iterator to the first character of the view. That’s the whole vibe πŸ¦‹.

Also, the original has a lil diagram reference: range-begin-end.svg πŸŽ€.


πŸŽ€ Parameters πŸŽ€

(none) β€” no parameters, not even a tiny one, bestie. Periodt.


πŸ’œ Return value πŸ’œ

const_iterator to the first character. Slay.


🌸 Complexity 🌸

Constant. Lowkey the easiest complexity to remember πŸ”₯.


πŸ‘‘ 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)

That’s the whole page, bestie 🫢. Source/version/date: http://cppreference.com, 2024.06.10, page std::basic_...iew::cbegin(3). Mwah πŸ’‹

πŸ“¦ where this page comes from