std::shared_ptr<T>:: operator*, std::shared_ptr<T>:: operator->
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Modifiers | ||||
| Observers | ||||
|
shared_ptr::operator*
shared_ptr::operator->
|
||||
|
(C++17)
|
||||
|
(
until C++20*
)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
| Non-member functions | ||||
|
(until C++20)
(until C++20)
(until C++20)
(until C++20)
(until C++20)
(C++20)
|
||||
|
functions
(
until C++26*
)
|
||||
| Helper classes | ||||
|
(C++20)
|
||||
| Deduction guides (C++17) |
|
T
&
operator
*
(
)
const
noexcept
;
|
(1) | (C++11以降) |
|
T
*
operator
-
>
(
)
const
noexcept
;
|
(2) | (C++11以降) |
格納されたポインタをデリファレンスします。格納されたポインタがnullの場合の動作は未定義です。
目次 |
パラメータ
(なし)
戻り値
備考
T
が
配列型または(possibly cv-qualified)
(since C++17)
void
の場合、関数
(1)
が宣言されるかどうかは未規定です。宣言される場合、その戻り値の型が何であるかは未規定ですが、関数の宣言(必ずしも定義ではない)は適格でなければなりません。これにより
std::
shared_ptr
<
void
>
のインスタンス化が可能になります。
|
|
(C++17以降) |
例
#include <iostream> #include <memory> struct Foo { Foo(int in) : a(in) {} void print() const { std::cout << "a = " << a << '\n'; } int a; }; int main() { auto ptr = std::make_shared<Foo>(10); ptr->print(); (*ptr).print(); }
出力:
a = 10 a = 10
関連項目
|
格納されたポインタを返す
(公開メンバ関数) |