GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::basic_string::crend - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string
  3. basic_string
  4. crend

最終更新日時: 2026年08月27日 14時02分35秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<string>

std::basic_string::crend(C++11)

const_reverse_iterator crend() const noexcept;           // (1) C++11
constexpr const_reverse_iterator crend() const noexcept; // (1) C++20

概要

先頭の前を指す逆イテレータを取得する。

戻り値

reverse_iterator(begin())

例外

投げない

例

#include <iostream>
#include <string>
#include <algorithm>

int main()
{
  std::string s = "hello";

  // 文字列オブジェクトsに含まれる、全ての要素を逆順に出力
  std::for_each(s.crbegin(), s.crend(), [](char c) {
    std::cout << c << std::endl;
  });
}

出力

o
l
l
e
h

参照

  • P0980R1 Making std::string constexpr
  • LWG Issue 1192. basic_string missing definitions for cbegin / cend / crbegin / crend
    • C++11で、これらのメンバ関数が追加された。ほかのコンテナには追加されていたが、basic_stringには記載が漏れていた
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.