Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::pointer_traits<Ptr>::pointer_to

      From cppreference.com
      <cpp‎ |memory‎ |pointer traits
       
       
      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::pointer_traits
      Member functions
      pointer_traits::pointer_to
      (C++11)
       
      Defined in header<memory>
      static pointer
      pointer_to( element_type& r);
      (1)(since C++11)
      (member ofpointer_traits<Ptr> specialization)
      (2)
      static pointer
      pointer_to( element_type& r)noexcept;
      (since C++11)
      (until C++20)
      (member ofpointer_traits<T*> specialization)
      staticconstexpr pointer
      pointer_to( element_type& r)noexcept;
      (since C++20)
      (member ofpointer_traits<T*> specialization)

      Constructs a dereferenceable pointer or pointer-like object ("fancy pointer") to its argument.

      1) The version of this function in the non-specializedstd::pointer_traits template simply callsPtr::pointer_to(r), and if Ptr does not provide a static member functionpointer_to, instantiation of this function is a compile-time error.
      2) The version of this function in the specialization ofstd::pointer_traits for pointer types returnsstd::addressof(r).

      Contents

      [edit]Parameters

      r - reference to an object of typeelement_type&, except if element_type isvoid, in which case the type ofr is unspecified

      [edit]Return value

      A dereferenceable pointer tor, of the typepointer_traits<>::pointer.

      [edit]Exceptions

      1) Unspecified (typically same asPtr::pointer_to).

      [edit]Notes

      TheBoost.Intrusive library version of this function returnspointer(std::addressof(r)) ifPtr::pointer_to does not exist.

      [edit]See also

      (C++11)
      obtains actual address of an object, even if the& operator is overloaded
      (function template)[edit]
      (until C++20)
      obtains the address of an object, even ifoperator& is overloaded
      (public member function ofstd::allocator<T>)[edit]
      [static](C++20)(optional)
      obtains a raw pointer from a fancy pointer (inverse ofpointer_to)
      (public static member function)[edit]
      (C++20)
      obtains a raw pointer from a pointer-like type
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/pointer_traits/pointer_to&oldid=153371"

      [8]ページ先頭

      ©2009-2025 Movatter.jp