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_const_iterator::iter_move (非メンバ関数) - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. iterator
  3. basic_const_iterator
  4. iter_move (非メンバ関数)

最終更新日時: 2026年08月18日 11時14分12秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<iterator>

std::basic_const_iterator::iter_move (非メンバ関数)(C++23)

friend constexpr rvalue-reference iter_move(const basic_const_iterator& i) noexcept(see below);

概要

basic_const_iteratorであるiの指す要素をムーブする。

戻り値のrvalue-referenceは次のように求められるconstかつ右辺値となる型である

using rvalue-reference = common_reference_t<const iter_value_t<Iterator>&&, iter_rvalue_reference_t<Iterator>>;

戻り値

ラップしているイテレータをcurrent_メンバ変数に保持するとして、次のようになる

return static_cast<rvalue-reference>(ranges::iter_move(i.current_));

例外

noexcept指定には次の式が指定される

noexcept(static_cast<rvalue-reference>(ranges::iter_move(i.current_)))

備考

この関数はHidden friendsとして定義される。

例

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

int main() {
  std::vector vec = {1, 2, 3, 4, 5};

  std::basic_const_iterator cit = vec.begin();

  // ADLによる呼び出し
  int n1 = iter_move(cit);
  std::cout << n1 << std::endl;

  ++cit;

  // ranges::iter_move CPOによる呼び出し
  int n2 = std::ranges::iter_move(cit);
  std::cout << n2 << std::endl;
}

出力

1
2

バージョン

言語

  • C++23

処理系

  • Clang: ??
  • GCC: 13.1 ✅
  • Visual C++: 2022 Update 6 ✅

参照

  • P2278R4 cbegin should always return a constant iterator
  • LWG Issue 3872. basic_const_iterator should have custom iter_move
    • C++23で、as_const後にas_rvalueを適用しても効かない不整合を解消するため、専用のiter_moveが追加された
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.