mirror of
https://github.com/boostorg/core.git
synced 2025-05-12 05:31:40 +00:00
Update pointer_traits documentation
This commit is contained in:
parent
09f4823baa
commit
a87fd099e7
@ -27,16 +27,15 @@ for obtaining raw pointers from pointers.
|
|||||||
|
|
||||||
[section Examples]
|
[section Examples]
|
||||||
|
|
||||||
The following function template obtains a raw pointer from a pointer and is
|
The following example allocates storage and constructs an object in that
|
||||||
well defined when the pointer aliases storage that has no object constructed
|
storage using an allocator.
|
||||||
in it.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
template<class T>
|
template<class Allocator>
|
||||||
inline typename boost::pointer_traits<T>::element_type*
|
void function(Allocator& a)
|
||||||
to_raw_pointer(T v) noexcept
|
|
||||||
{
|
{
|
||||||
return boost::pointer_traits<T>::to_address(v);
|
auto p = a.allocate(1);
|
||||||
|
std::allocator_traits<Allocator>::construct(a, boost::to_address(p));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ namespace boost {
|
|||||||
template<class U> using rebind = typename rebind_to<U>::type;
|
template<class U> using rebind = typename rebind_to<U>::type;
|
||||||
|
|
||||||
static pointer pointer_to(``['see below]`` v);
|
static pointer pointer_to(``['see below]`` v);
|
||||||
static element_type* to_address(pointer v) noexcept;
|
static element_type* to_address(const pointer& v) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T> struct pointer_traits<T*> {
|
template<class T> struct pointer_traits<T*> {
|
||||||
@ -69,63 +68,64 @@ namespace boost {
|
|||||||
static pointer pointer_to(``['see below]`` v) noexcept;
|
static pointer pointer_to(``['see below]`` v) noexcept;
|
||||||
static element_type* to_address(pointer v) noexcept;
|
static element_type* to_address(pointer v) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename pointer_traits<T>::element_type* to_address(const T& v) noexcept;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
[section Member types]
|
[section Member types]
|
||||||
|
|
||||||
[variablelist
|
[variablelist
|
||||||
[[`typedef` ['see below] `element_type;`]
|
[[`typedef` ['see below] `element_type;`]
|
||||||
[[variablelist
|
[`T::element_type` if such a type exists; otherwise `U` if `T` is a class
|
||||||
[[Type]
|
template instantiation of the form `Pointer<U, Args>`, where `Args` is zero
|
||||||
[`T::element_type` if such a type exists; otherwise `U` if `T` is a
|
or more type arguments; otherwise the specialization is ill-formed.]]
|
||||||
class template instantiation of the form `Pointer<U, Args>`, where
|
[[`typedef` ['see below] `difference_type;`]
|
||||||
`Args` is zero or more type arguments; otherwise the specialization
|
[`T::difference_type` if such a type exists; otherwise `std::ptrdiff_t`.]]
|
||||||
is ill-formed.]]]]]
|
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
||||||
[[`typedef` ['see below] `difference_type;`]
|
[`type` is `T::rebind<U>` if such a type exists; otherwise, `Pointer<V, Args>`
|
||||||
[[variablelist
|
if `T` is a class template instantiation of the form `Pointer<T, Args>`,
|
||||||
[[Type]
|
where `Args` is zero or more type arguments; otherwise, the instantiation of
|
||||||
[`T::difference_type` if such a type exists; otherwise
|
`rebind_to` is ill-formed.]]]
|
||||||
`std::ptrdiff_t`.]]]]]
|
|
||||||
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
|
||||||
[[variablelist
|
|
||||||
[[Type]
|
|
||||||
[`type` is `T::rebind<U>` if such a type exists; otherwise,
|
|
||||||
`Pointer<V, Args>` if `T` is a class template instantiation of the
|
|
||||||
form `Pointer<T, Args>`, where `Args` is zero or more type
|
|
||||||
arguments; otherwise, the instantiation of `rebind_to` is
|
|
||||||
ill-formed.]]]]]]
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section Member functions]
|
[section Member functions]
|
||||||
|
|
||||||
[variablelist pointer_traits
|
[variablelist pointer_traits
|
||||||
[[`static pointer pointer_to(`['see below] `v);`]
|
[[`static pointer pointer_to(`['see below] `v);`]
|
||||||
[[variablelist
|
[[variablelist
|
||||||
[[Remark]
|
[[Remark]
|
||||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||||
otherwise, it is `element_type&`.]]
|
it is `element_type&`.]]
|
||||||
[[Returns]
|
[[Returns]
|
||||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
[[`static element_type* to_address(const pointer& v) noexcept;`]
|
||||||
[[variablelist
|
[[variablelist
|
||||||
[[Requires]
|
[[Requires] [`v` is not a null pointer.]]
|
||||||
[`v` is not a null pointer.]]
|
[[Returns]
|
||||||
[[Returns]
|
[A pointer of type `element_type*` that references the same location
|
||||||
[A pointer of type `element_type*` that references the same location
|
as the argument.]]]]]]
|
||||||
as the argument.]]]]]]
|
|
||||||
|
|
||||||
[variablelist pointer_traits<T*>
|
[variablelist pointer_traits<T*>
|
||||||
[[`static pointer pointer_to(`['see below] `v) noexcept;`]
|
[[`static pointer pointer_to(`['see below] `v) noexcept;`]
|
||||||
[[variablelist
|
[[variablelist
|
||||||
[[Remark]
|
[[Remark]
|
||||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||||
otherwise, it is `element_type&`.]]
|
it is `element_type&`.]]
|
||||||
[[Returns]
|
[[Returns] [The result of `std::addressof(v)`.]]]]]
|
||||||
[The result of `std::addressof(v)`.]]]]]
|
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
[[variablelist [[Returns] [The value of `v`.]]]]]]
|
||||||
[[variablelist [[Returns] [The value of `v`.]]]]]]
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Free functions]
|
||||||
|
|
||||||
|
[variablelist
|
||||||
|
[[`template<class T> typename pointer_traits<T>::element_type*
|
||||||
|
to_address(const T& v);`]
|
||||||
|
[[variablelist [[Returns] [`pointer_traits<T>::to_address(v)`.]]]]]]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user