std::pointer_traits<Ptr>::pointer_to
From cppreference.com
< cpp | memory | pointer traits
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
Uninitialized storage (until C++20)
(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)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
Defined in header
<memory>
static pointer
pointer_to( element_type& r );
(1)
(since C++11) pointer_to( element_type& r );
(member of
pointer_traits<Ptr>
specialization)
(2)
static pointer
pointer_to( element_type& r ) noexcept;
(since C++11) pointer_to( element_type& r ) noexcept;
(until C++20)
(member of
pointer_traits<T*>
specialization)
static constexpr pointer
pointer_to( element_type& r ) noexcept;
(since C++20) pointer_to( element_type& r ) noexcept;
(member of
pointer_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-specialized std::pointer_traits template simply calls Ptr::pointer_to(r), and if Ptr does not provide a static member function
pointer_to
, instantiation of this function is a compile-time error.2) The version of this function in the specialization of std::pointer_traits for pointer types returns std::addressof (r).
[edit] Parameters
r
-
reference to an object of type element_type&, except if element_type is void, in which case the type of
r
is unspecified
[edit] Return value
A dereferenceable pointer to r, of the type pointer_traits<>::pointer.
[edit] Exceptions
1) Unspecified (typically same as Ptr::pointer_to).
[edit] Notes
The Boost.Intrusive library version of this function returns pointer(std::addressof (r)) if Ptr::pointer_to does not exist.
[edit] See also
(C++11)
&
operator is overloaded (function template) [edit]
(until C++20)
(public member function of
std::allocator<T>
) [edit]
[static] (C++20)(optional)
pointer_to
) (public static member function) [edit]