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

  1. リファレンス
  2. iterator
  3. reverse_iterator
  4. operator->

最終更新日時: 2026年08月27日 11時21分44秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<iterator>

std::reverse_iterator::operator->

pointer operator->() const;           // (1) C++98
constexpr pointer operator->() const; // (1) C++17
constexpr pointer operator->() const  // (1) C++20
  requires (is_pointer_v<Iterator> ||
            requires (const Iterator i) { i.operator->(); });

概要

イテレータを通してオブジェクトにアクセスする

戻り値

  • C++98 : &(operator*())
  • C++14 : addressof(operator*())
  • C++20 : 次のいずれか

    • Iteratorがポインタ型である場合

      return prev(current);
      

    • それ以外の場合

    return prev(current).operator->();
    

例

#include <iostream>
#include <vector>
#include <iterator>

class value {
  int x;

public:
  value(int x = 0) : x(x) {}
  int get() const { return x; }
};

int main()
{
  std::vector<value> v = {1, 2, 3};

  std::reverse_iterator<decltype(v)::iterator> it(v.end());

  int result = it->get();

  std::cout << result << std::endl;
}

出力

3

参照

  • LWG Issue 2188. Reverse iterator does not fully support targets that overload operator&
  • P0031R0 A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access
  • P0896R4 The One Ranges Proposal (was Merging the Ranges TS)
You are visitor 01402520 — 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.