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
가
배열 타입이거나 (가능한 cv-qualified)
(C++17부터)
void
인 경우, 함수
(1)
이 선언되는지 여부는 명시되지 않습니다. 선언되는 경우, 그 반환 타입이 무엇인지 명시되지 않으나, 함수의 선언(정의는 아니더라도)이 올바르게 형성되어야 합니다. 이로 인해
std::
shared_ptr
<
void
>
의 인스턴스화가 가능해집니다.
|
|
(since 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
참고 항목
|
저장된 포인터를 반환합니다
(public member function) |