Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.29 KB

File metadata and controls

65 lines (46 loc) · 1.29 KB

operator->

  • memory[meta header]
  • std[meta namespace]
  • indirect[meta class]
  • function[meta id-type]
  • cpp26[meta cpp]
constexpr const_pointer operator->() const noexcept; // (1)
constexpr pointer operator->() noexcept;             // (2)

概要

所有するオブジェクトのメンバへアクセスするためのポインタを取得する。

事前条件

*thisが無効値状態でないこと。

戻り値

所有するオブジェクトを指すポインタ。

例外

投げない。

#include <cassert>
#include <memory>
#include <string>

int main()
{
  std::indirect<std::string> s{std::string{"hello"}};
  assert(s->size() == 5);  // 所有するstringのメンバにアクセス
  s->push_back('!');
  assert(*s == "hello!");
}
  • std::indirect[link ../indirect.md]

出力

バージョン

言語

  • C++26

処理系

  • Clang: 22 [mark noimpl]
  • GCC: 16.1 [mark verified]
  • Visual C++: 2026 Update 2 [mark noimpl]

関連項目

参照