Namespaces
Variants

std::shared_ptr<T>:: owner_equal

From cppreference.net

Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
template < class Y >
bool owner_equal ( const std:: shared_ptr < Y > & other ) const noexcept ;
(1) (C++26부터)
template < class Y >
bool owner_equal ( const std:: weak_ptr < Y > & other ) const noexcept ;
(2) (C++26부터)

shared_ptr other 가 소유권을 공유하거나 둘 다 비어 있는지 확인합니다. 두 스마트 포인터는 둘 다 비어 있거나 동일한 객체를 소유하는 경우에만 동등하게 비교되며, get() 로 얻은 포인터 값이 다르더라도 (예: 동일한 객체 내의 다른 하위 객체를 가리키는 경우) 마찬가지입니다.

멤버 함수 owner_equal 는 다음과 같은 동치 관계입니다: ! owner_before ( other ) && ! other. owner_before ( * this ) true 인 경우에만, 그리고 그 경우에 owner_equal ( other ) true 입니다.

이 순서 지정은 공유 포인터와 약한 포인터를 비정렬 연관 컨테이너의 키로 사용할 수 있게 하기 위해 사용되며, 일반적으로 std::owner_equal 를 통해 구현됩니다.

목차

매개변수

other - 비교할 std::shared_ptr 또는 std::weak_ptr

반환값

true 를 반환합니다, 만약 * this other 가 소유권을 공유하거나 둘 다 비어 있는 경우. 그렇지 않으면 false 를 반환합니다.

참고 사항

기능 테스트 매크로 표준 기능
__cpp_lib_smart_ptr_owner_equality 202306L (C++26) std::shared_ptr 비정렬 연관 컨테이너 에서 키로 사용 가능하게 함

예제

참고 항목

공유 포인터와 약한 포인터의 혼합 타입 소유자 기반 동등 비교를 제공함
(클래스)