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

  1. リファレンス
  2. optional
  3. optional
  4. end

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<optional>

std::optional::end(C++26)

constexpr iterator end() noexcept; // (1)
constexpr const_iterator end() const noexcept; // (2)

概要

optionalをrangeとした時の末尾要素の次を指すイテレータを取得する。

効果

begin() + has_value() を返す。

例

#include <iostream>
#include <iterator>
#include <optional>

int main()
{
  std::optional<int> p = 1;
  std::cout << std::distance(p.begin(), p.end()) << std::endl;

  p = std::nullopt;
  std::cout << std::distance(p.begin(), p.end()) << std::endl;
}

出力

1
0

バージョン

言語

  • C++26

処理系

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

参照

  • P3168R2 Give std::optional Range Support
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.