- string[meta header]
- std[meta namespace]
- basic_string[meta class]
- function[meta id-type]
iterator begin(); // (1) C++03
iterator begin() noexcept; // (1) C++11
constexpr iterator begin() noexcept; // (1) C++20
const_iterator begin() const; // (2) C++03
const_iterator begin() const noexcept; // (2) C++11
constexpr const_iterator begin() const noexcept; // (2) C++20
文字列の先頭を指すイテレータを取得する。
先頭を指すイテレータ。
投げない
#include <iostream>
#include <string>
int main()
{
std::string s = "hello";
// 先頭へのイテレータを取得
decltype(s)::iterator it = s.begin();
// イテレータが指している要素を参照
char& c = *it;
std::cout << c << std::endl;
}
- begin()[color ff0000]
h