// 非配列版のみ T* operator->() const noexcept;
概要
ポインタを通してオブジェクトにアクセスする。
要件
get() != nullptr
戻り値
備考
型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
処理系
- GCC: 4.3.6
- Clang libc++, C++11 mode: 3.0
- ICC: ?
- Visual C++: 2008 (TR1), 2010, 2012, 2013