std::basic_string::end,(3)
okay bestie, this is std::basic_string::end,(3) from the C++ Standard Libary manual, and it's literally the page for std::basic_string's end/cend situation π no cap.
π NAME π
std::basic_string::end, - std::basic_string::end,
yes, that's the NAME line verbatim, comma chaos and all β she's a little quirky but iconic π
πΈ Synopsis πΈ
iterator end(); (1) (noexcept since C++11)
(constexpr since C++20)
const_iterator end() const; (2) (noexcept since C++11)
(constexpr since C++20)
const_iterator cend() const noexcept; (3) (since C++11)
(constexpr since C++20)
Okay so this returns an iterator to the character following the last character of the string. That character acts as a placeholder, and bestie, attempting to access it results in undefined behavior π β like, do not mess with the placeholder, fr fr.
The original page also has range-begin-end.svg chilling right here β iconic filename moment π.
π Parameters π
(none) β not a single parameter, zero, nada, the void π.
β Return value β
Iterator to the character following the last character. That's the whole return value, and it ate π .
π₯ Complexity π₯
Constant. That's it. Constant. periodt β.
π Notes π
libc++ backports cend() to C++98 mode. β that's the note, and it's lowkey a C++98 backport moment π«Ά.
π» Example π»
The original says // Run this code, so here's the code verbatim, bestie:
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
int main()
{
std::string s("Exemparl");
std::next_permutation(s.begin(), s.end());
std::string c;
std::copy(s.cbegin(), s.cend(), std::back_inserter(c));
std::cout << c << '\n'; // "Exemplar"
}
π Output: π
Exemplar
π¦ See also π¦
beginβ returns an iterator to the beginningcbeginβ(public member function)(C++11)endβ returns an iterator to the endcendβ(public member function of std::basic_string_view<CharT,Traits>)
mwah π β source/version and date: http://cppreference.com Β· 2024.06.10 πΈ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms