Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1019 Bytes

File metadata and controls

60 lines (44 loc) · 1019 Bytes

operator->

  • memory[meta header]
  • std[meta namespace]
  • unique_ptr[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
pointer operator->() const noexcept;           // (1) C++11
constexpr pointer operator->() const noexcept; // (1) C++23

概要

ポインタを通してオブジェクトにアクセスする。

要件

get() != nullptr
  • get()[link get.md]

戻り値

get()

#include <iostream>
#include <memory>
#include <string>

int main()
{
  std::unique_ptr<std::string> p(new std::string("hello"));

  std::cout << p->c_str() << std::endl;
}

出力

hello

バージョン

言語

  • C++11

処理系

参照