Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::weak_ptr<T>::operator=

      From cppreference.com
      <cpp‎ |memory‎ |weak ptr
       
       
      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)
       
       
      weak_ptr& operator=(const weak_ptr& r)noexcept;
      (1)(since C++11)
      template<class Y>
      weak_ptr& operator=(const weak_ptr<Y>& r)noexcept;
      (2)(since C++11)
      template<class Y>
      weak_ptr& operator=(const shared_ptr<Y>& r)noexcept;
      (3)(since C++11)
      weak_ptr& operator=( weak_ptr&& r)noexcept;
      (4)(since C++11)
      template<class Y>
      weak_ptr& operator=( weak_ptr<Y>&& r)noexcept;
      (5)(since C++11)

      Replaces the managed object with the one managed byr. The object is shared withr. Ifr manages no object,*this manages no object too.

      1-3) Equivalent tostd::weak_ptr<T>(r).swap(*this).
      4,5) Equivalent tostd::weak_ptr<T>(std::move(r)).swap(*this).

      Contents

      [edit]Parameters

      r - smart pointer to share an object with

      [edit]Return value

      *this

      [edit]Notes

      The implementation may meet the requirements without creating a temporaryweak_ptr object.

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2315C++11move semantic was not enabled forweak_ptrenabled

      [edit]See also

      creates a newweak_ptr
      (public member function)[edit]
      swaps the managed objects
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/weak_ptr/operator%3D&oldid=153991"

      [8]ページ先頭

      ©2009-2025 Movatter.jp