std::pointer_traits::pointer_to - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::pointer_traits::pointer_to

From cppreference.com
< cpp‎ | memory‎ | pointer traits

Defined in header `<memory>` |  |
static pointer pointer_to( element_type& r ); | (1) | (since C++11) (member of `pointer_traits<Ptr>` specialization)
static pointer pointer_to( element_type& r ); | (2) | (since C++11) (member of `pointer_traits<T*>` specialization)

Constructs a dereferenceable 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)
2)
`noexcept` specification:
noexcept

### [edit] Notes

The boost library version of this function returns pointer(std::addressof(r)) if Ptr::pointer_to does not exist.

### [edit] See also

addressof (C++11) | obtains actual address of an object, even if the & operator is overloaded (function template) [edit]
address | obtains the address of an object, even if operator& is overloaded (public member function of `std::allocator`) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/memory/pointer_traits/pointer_to&oldid=64891"
Category:

- unconditionally noexcept