Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::static_pointer_cast,std::experimental::dynamic_pointer_cast,std::experimental::const_pointer_cast,std::experimental::reinterpret_pointer_cast

      From cppreference.com
      <cpp‎ |experimental‎ |shared ptr
       
       
       
       
      std::experimental::shared_ptr
      Member functions
      Non-member functions
      experimental::static_pointer_castexperimental::dynamic_pointer_castexperimental::const_pointer_castexperimental::reinterpret_pointer_cast
      Members and non-members identical to those ofstd::shared_ptr
       
      template<class T,class U>

      std::experimental::shared_ptr<T>

          static_pointer_cast(conststd::experimental::shared_ptr<U>& r)noexcept;
      (1)(library fundamentals TS)
      template<class T,class U>

      std::experimental::shared_ptr<T>

          dynamic_pointer_cast(conststd::experimental::shared_ptr<U>& r)noexcept;
      (2)(library fundamentals TS)
      template<class T,class U>

      std::experimental::shared_ptr<T>

          const_pointer_cast(conststd::experimental::shared_ptr<U>& r)noexcept;
      (3)(library fundamentals TS)
      template<class T,class U>

      std::experimental::shared_ptr<T>

          reinterpret_pointer_cast(conststd::experimental::shared_ptr<U>& r)noexcept;
      (4)(library fundamentals TS)

      Creates a new instance ofstd::experimental::shared_ptr whose stored pointer is obtained fromr's stored pointer using a cast expression. Ifr is empty, so is the newshared_ptr (but its stored pointer is not necessarily null).

      Otherwise, the newshared_ptr will share ownership withr, except that it is empty if thedynamic_cast performed bydynamic_pointer_cast returns a null pointer.

      LetY betypenamestd::experimental::shared_ptr<T>::element_type, then the resultingstd::experimental::shared_ptr's stored pointer will be obtained by calling (in respective order):

      1)static_cast<Y*>(r.get()).
      2)dynamic_cast<Y*>(r.get()) (if the result of thedynamic_cast is a null pointer value, the returnedshared_ptr will be empty).
      3)const_cast<Y*>(r.get()).
      4)reinterpret_cast<Y*>(r.get()).

      The behavior of these functions is undefined unless the corresponding cast fromU* toT* is well formed:

      1) The behavior is undefined unlessstatic_cast<T*>((U*)nullptr) is well formed.
      2) The behavior is undefined unlessdynamic_cast<T*>((U*)nullptr) is well formed.
      3) The behavior is undefined unlessconst_cast<T*>((U*)nullptr) is well formed.
      4) The behavior is undefined unlessreinterpret_cast<T*>((U*)nullptr) is well formed.

      [edit]Parameters

      r - the pointer to convert

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      constructs newshared_ptr
      (public member function)[edit]
      appliesstatic_cast,dynamic_cast,const_cast, orreinterpret_cast to the stored pointer
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/shared_ptr/pointer_cast&oldid=156223"

      [8]ページ先頭

      ©2009-2026 Movatter.jp