- string[meta header]
- std[meta namespace]
- basic_string[meta class]
- function[meta id-type]
- cpp11[meta cpp]
const_iterator cbegin() const noexcept; // (1) C++11
constexpr const_iterator cbegin() const noexcept; // (1) C++20文字列の先頭を指す読み取り専用イテレータを取得する。
先頭を指す読み取り専用イテレータ。
投げない
#include <iostream>
#include <string>
int main()
{
std::string s = "hello";
// 先頭へのイテレータを取得
decltype(s)::const_iterator it = s.cbegin();
// イテレータが指している要素を参照
const char& c = *it;
std::cout << c << std::endl;
}- cbegin()[color ff0000]
h
- P0980R1 Making
std::stringconstexpr - LWG Issue 1192.
basic_stringmissing definitions for cbegin / cend / crbegin / crend- C++11で、これらのメンバ関数が追加された。ほかのコンテナには追加されていたが、
basic_stringには記載が漏れていた
- C++11で、これらのメンバ関数が追加された。ほかのコンテナには追加されていたが、