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

  1. リファレンス
  2. algorithm
  3. out_value_result

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

履歴 編集

class template
<algorithm>

std::ranges::out_value_result(C++23)

namespace std::ranges {
  // (1)
  template<class O, class T>
  struct out_value_result {
    [[no_unique_address]] O out;
    [[no_unique_address]] T value;

    template<class O2, class T2>
      requires convertible_to<const O&, O2> && convertible_to<const T&, T2>
    constexpr operator out_value_result<O2, T2>() const & {
      return {out, value};
    }

    template<class O2, class T2>
      requires convertible_to<O, O2> && convertible_to<T, T2>
    constexpr operator out_value_result<O2, T2>() && {
      return {std::move(out), std::move(value)};
    }
  };

  // (2)
  template< class O, class T >
  using iota_result = out_value_result<O, T>;
}

概要

  • (1): イテレータと値を格納する型
  • (2): ranges::iotaで使用するエイリアス

この型は、関数が出力用に範囲を受け取る場合に、処理した範囲の末尾と、それとは別の出力を返すために使用される。

標準アルゴリズム関数ではこの型を直接返す代わりに、関数毎にエイリアスを定義している。

メンバ変数

名前 説明 対応バージョン
[[no_unique_address]] O out 出力した範囲の末尾 C++23
[[no_unique_address]] T value イテレータとは別の値 C++23

メンバ関数

名前 説明 対応バージョン
operator out_value_result<O2, T2> 変換演算子 C++23

変換演算子は、各テンプレートパラメーターが変換できる場合のみオーバーロード解決に参加する。

例

#include <cassert>
#include <numeric>
#include <vector>

int main() {
  std::vector<int> v(5);

  // ranges::iotaはout_value_result(iota_result)を返す
  const std::ranges::out_value_result result = std::ranges::iota(v, 0);

  assert(result.out == v.end()); // 書き込み終えた終端イテレータ
  assert(result.value == 5);     // 次に書き込むはずの値
  // v は {0, 1, 2, 3, 4}
}

出力

バージョン

言語

  • C++23

処理系

  • Clang: 21.1.7 ✅
  • GCC: ??
  • Visual C++: ??

参照

  • N4901 25 Algorithms library
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.