std::unique_ptr<T,Deleter>::get
提供: cppreference.com
<tbody>
</tbody>
pointer get() const noexcept; |
(C++11以上) | |
管理対象オブジェクトを指すポインタ、または所有しているオブジェクトがなければ nullptr を返します。
引数
(なし)
戻り値
管理対象オブジェクトを指すポインタ、または所有しているオブジェクトがなければ nullptr。
例
Run this code
#include <iostream>
#include <string>
#include <memory>
int main()
{
std::unique_ptr<std::string> s_p(new std::string("Hello, world!"));
std::string *s = s_p.get();
std::cout << *s << '\n';
}
出力:
Hello, world!
関連項目
| 管理対象オブジェクトへのポインタを返し、所有権を解放します (パブリックメンバ関数) |