Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::shared_ptr<T>::owner_equal

      From cppreference.com
      <cpp‎ |memory‎ |shared ptr

      [edit template]
       
       
      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*)
      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)
       
      std::shared_ptr
      Member functions
      Modifiers
      Observers
      (until C++20*)
      shared_ptr::owner_equal
      (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
      Deduction guides(C++17)
       
      template<class Y>
      bool owner_equal(conststd::shared_ptr<Y>& other)constnoexcept;
      (1)(since C++26)
      template<class Y>
      bool owner_equal(conststd::weak_ptr<Y>& other)constnoexcept;
      (2)(since C++26)

      Checks whether thisshared_ptr andother share ownership or are both empty. The comparison is such that two smart pointers compare equivalent only if they are both empty or if they both own the same object, even if the values of the pointers obtained byget() are different (e.g. because they point at different subobjects within the same object).

      The member functionowner_equal is an equivalence relation such that!owner_before(other)&&!other.owner_before(*this) istrue if and only ifowner_equal(other) istrue.

      This ordering is used to make shared and weak pointers usable as keys in unordered associative containers, typically throughstd::owner_equal.

      Contents

      [edit]Parameters

      other - thestd::shared_ptr orstd::weak_ptr to be compared

      [edit]Return value

      true if*this andother share ownership or are both empty. Otherwise, returnsfalse.

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_smart_ptr_owner_equality202306L(C++26)Enabling the use ofstd::shared_ptr as keys inunordered associative containers

      [edit]Example

      This section is incomplete
      Reason: example

      [edit]See also

      provides mixed-type owner-based equal comparisons of shared and weak pointers
      (class)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/shared_ptr/owner_equal&oldid=165925"

      [8]ページ先頭

      ©2009-2025 Movatter.jp