diff --git a/doc/pointer_traits.qbk b/doc/pointer_traits.qbk index fe43e46..fbb20ef 100644 --- a/doc/pointer_traits.qbk +++ b/doc/pointer_traits.qbk @@ -27,16 +27,15 @@ for obtaining raw pointers from pointers. [section Examples] -The following function template obtains a raw pointer from a pointer and is -well defined when the pointer aliases storage that has no object constructed -in it. +The following example allocates storage and constructs an object in that +storage using an allocator. ``` -template -inline typename boost::pointer_traits::element_type* -to_raw_pointer(T v) noexcept +template +void function(Allocator& a) { - return boost::pointer_traits::to_address(v); + auto p = a.allocate(1); + std::allocator_traits::construct(a, boost::to_address(p)); } ``` @@ -55,7 +54,7 @@ namespace boost { template using rebind = typename rebind_to::type; 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 struct pointer_traits { @@ -69,63 +68,64 @@ namespace boost { static pointer pointer_to(``['see below]`` v) noexcept; static element_type* to_address(pointer v) noexcept; }; + + template + typename pointer_traits::element_type* to_address(const T& v) noexcept; } ``` [section Member types] [variablelist - [[`typedef` ['see below] `element_type;`] - [[variablelist - [[Type] - [`T::element_type` if such a type exists; otherwise `U` if `T` is a - class template instantiation of the form `Pointer`, where - `Args` is zero or more type arguments; otherwise the specialization - is ill-formed.]]]]] - [[`typedef` ['see below] `difference_type;`] - [[variablelist - [[Type] - [`T::difference_type` if such a type exists; otherwise - `std::ptrdiff_t`.]]]]] - [[`template struct rebind_to { typedef` ['see below] `type; };`] - [[variablelist - [[Type] - [`type` is `T::rebind` if such a type exists; otherwise, - `Pointer` if `T` is a class template instantiation of the - form `Pointer`, where `Args` is zero or more type - arguments; otherwise, the instantiation of `rebind_to` is - ill-formed.]]]]]] +[[`typedef` ['see below] `element_type;`] +[`T::element_type` if such a type exists; otherwise `U` if `T` is a class + template instantiation of the form `Pointer`, where `Args` is zero + or more type arguments; otherwise the specialization is ill-formed.]] +[[`typedef` ['see below] `difference_type;`] +[`T::difference_type` if such a type exists; otherwise `std::ptrdiff_t`.]] +[[`template struct rebind_to { typedef` ['see below] `type; };`] +[`type` is `T::rebind` if such a type exists; otherwise, `Pointer` + if `T` is a class template instantiation of the form `Pointer`, + where `Args` is zero or more type arguments; otherwise, the instantiation of + `rebind_to` is ill-formed.]]] [endsect] [section Member functions] [variablelist pointer_traits - [[`static pointer pointer_to(`['see below] `v);`] - [[variablelist - [[Remark] - [If `element_type` is a void type, the type of `v` is unspecified; - otherwise, it is `element_type&`.]] - [[Returns] - [A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]] - [[`static element_type* to_address(pointer v) noexcept;`] - [[variablelist - [[Requires] - [`v` is not a null pointer.]] - [[Returns] - [A pointer of type `element_type*` that references the same location - as the argument.]]]]]] +[[`static pointer pointer_to(`['see below] `v);`] +[[variablelist +[[Remark] +[If `element_type` is a void type, the type of `v` is unspecified; otherwise, + it is `element_type&`.]] +[[Returns] +[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]] +[[`static element_type* to_address(const pointer& v) noexcept;`] +[[variablelist +[[Requires] [`v` is not a null pointer.]] +[[Returns] +[A pointer of type `element_type*` that references the same location + as the argument.]]]]]] [variablelist pointer_traits - [[`static pointer pointer_to(`['see below] `v) noexcept;`] - [[variablelist - [[Remark] - [If `element_type` is a void type, the type of `v` is unspecified; - otherwise, it is `element_type&`.]] - [[Returns] - [The result of `std::addressof(v)`.]]]]] - [[`static element_type* to_address(pointer v) noexcept;`] - [[variablelist [[Returns] [The value of `v`.]]]]]] +[[`static pointer pointer_to(`['see below] `v) noexcept;`] +[[variablelist +[[Remark] +[If `element_type` is a void type, the type of `v` is unspecified; otherwise, + it is `element_type&`.]] +[[Returns] [The result of `std::addressof(v)`.]]]]] +[[`static element_type* to_address(pointer v) noexcept;`] +[[variablelist [[Returns] [The value of `v`.]]]]]] + +[endsect] + +[section Free functions] + +[variablelist +[[`template typename pointer_traits::element_type* + to_address(const T& v);`] +[[variablelist [[Returns] [`pointer_traits::to_address(v)`.]]]]]] [endsect]