Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 923 Bytes

File metadata and controls

54 lines (40 loc) · 923 Bytes

base

  • ranges[meta header]
  • std::ranges[meta namespace]
  • ref_view[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
constexpr R& base() const; // (1) C++20

概要

元となるRangeへの参照を取得する。

戻り値

メンバ変数r_として保持しているRangeへのポインタがあるとして、以下を返す:

return *r_;

#include <cassert>
#include <vector>
#include <ranges>

int main() {
  std::vector<int> v = {1, 2, 3};
  auto r = std::ranges::ref_view(v);
  auto& base = r.base();

  assert(&base == &v);
}
  • base()[color ff0000]

出力

バージョン

言語

  • C++20

処理系

  • Clang: 13.0.0 [mark verified]
  • GCC: 10.1.0 [mark verified]
  • ICC: ?
  • Visual C++: 2019 Update 10 [mark verified]