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::array::crbegin - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. array
  3. array
  4. crbegin

最終更新日時: 2026年09月19日 21時31分51秒 (JST)
rotarymars が更新

履歴 編集

function
<array>

std::array::crbegin(C++11)

const_reverse_iterator crbegin() const noexcept;           // C++11
constexpr const_reverse_iterator crbegin() const noexcept; // C++17

概要

最後尾の要素を指す読み取り専用逆イテレータを取得する。

rbegin()は非constなarrayオブジェクトに対してreverse_iteratorを返し、constなarrayオブジェクトに対してはconst_reverse_iteratorを返すが、crbegin()はconst_reverse_iteratorを返すバージョンのみが提供されている。 アルゴリズムにイテレータの組を渡す際、アルゴリズム内でデータの書き換えが起こらないというユーザーの意図を示す場合などに有用である。

戻り値

最後尾の要素を指す読み取り専用逆イテレータ

例外

投げない

計算量

定数時間

例

#include <iostream>
#include <array>
#include <algorithm>

int main()
{
  std::array<int, 3> ar = {1, 2, 3};

  // このアルゴリズム内ではarの書き換えを決して行わない
  std::for_each(ar.crbegin(), ar.crend(), [](const int& x) {
    std::cout << x << std::endl;
  });
}

出力

3
2
1

バージョン

言語

  • C++11

処理系

  • Clang: 9.0.1 ✅
  • GCC: 4.7.0 ✅
  • Visual C++: 2010 ✅, 2012 ✅

参照

  • P0031R0 A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access
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.