最終更新日時(UTC):
が更新

履歴 編集

function
<memory>

std::shared_ptr::operator->(C++11)

// 非配列版のみ
T* operator->() const noexcept;

概要

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

要件

get() != nullptr

戻り値

get()

備考

Tが配列である場合、この関数が宣言されるかは未規定。定義される場合、その戻り値は未規定

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

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

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

出力

hello

バージョン

言語

  • C++11

処理系