BDE 4.14.0 Production release
|
Provide an ownership comparison for shared and weak pointers.
shared_ptr
and weak_ptr
Canonical header: bsl_memory.h
This component provides the C++26 standard binary comparison functor, bsl::owner_equal
, that determines the equality of two smart pointer objects by the address of their bslma::SharedPtrRep
data. Note that this class is an empty POD type.
This section illustrates intended use of this component.
Suppose we need an unordered map accepting shared pointers as keys. We also expect that this container will be accessible from multiple threads and some of them will store weak versions of smart pointers to break reference cycles.
First, we create a container and populate it:
Then we make sure that shared pointers can be used to perform lookup, and verify that the results are correct.
Finally, we simulate the accessing the container from another thread and perform lookup using weak pointers: