Skip to content

Commit 3454b8f

Browse files
committed
Merge 2017-11 LWG Motion 12
2 parents 2b8bea7 + d2db3c1 commit 3454b8f

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

source/utilities.tex

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6492,6 +6492,12 @@
64926492
template <class Ptr> struct pointer_traits;
64936493
template <class T> struct pointer_traits<T*>;
64946494

6495+
// \ref{pointer.conversion}, pointer conversion
6496+
template <class Ptr>
6497+
auto to_address(const Ptr& p) noexcept;
6498+
template <class T>
6499+
constexpr T* to_address(T* p) noexcept;
6500+
64956501
// \ref{util.dynamic.safety}, pointer safety
64966502
enum class pointer_safety { relaxed, preferred, strict };
64976503
void declare_reachable(void* p);
@@ -6903,6 +6909,60 @@
69036909
function. The second member function returns \tcode{addressof(r)}.
69046910
\end{itemdescr}
69056911

6912+
\rSec3[pointer.traits.optmem]{Pointer traits optional members}
6913+
6914+
\pnum
6915+
Specializations of \tcode{pointer_traits} may define the member declared
6916+
in this subclause to customize the behavior of the standard library.
6917+
6918+
\indexlibrarymember{to_address}{pointer_traits}%
6919+
\begin{itemdecl}
6920+
static element_type* to_address(pointer p) noexcept;
6921+
\end{itemdecl}
6922+
6923+
\begin{itemdescr}
6924+
\pnum
6925+
\returns
6926+
A pointer of type \tcode{element_type*} that references
6927+
the same location as the argument \tcode{p}.
6928+
6929+
\pnum
6930+
\begin{note}
6931+
This function should be the inverse of \tcode{pointer_to}.
6932+
If defined, it customizes the behavior of
6933+
the non-member function
6934+
\tcode{to_address}\iref{pointer.conversion}.
6935+
\end{note}
6936+
\end{itemdescr}
6937+
6938+
\rSec2[pointer.conversion]{Pointer conversion}
6939+
6940+
\indexlibrary{\idxcode{to_address}}%
6941+
\begin{itemdecl}
6942+
template <class Ptr> auto to_address(const Ptr& p) noexcept;
6943+
\end{itemdecl}
6944+
6945+
\begin{itemdescr}
6946+
\pnum
6947+
\returns
6948+
\tcode{pointer_traits<Ptr>::to_address(p)} if that expression is well-formed
6949+
(see \ref{pointer.traits.optmem}),
6950+
otherwise \tcode{to_address(p.operator->())}.
6951+
\end{itemdescr}
6952+
6953+
\indexlibrary{\idxcode{to_address}}%
6954+
\begin{itemdecl}
6955+
template <class T> constexpr T* to_address(T* p) noexcept;
6956+
\end{itemdecl}
6957+
6958+
\begin{itemdescr}
6959+
\pnum
6960+
\requires \tcode{T} is not a function type. Otherwise the program is ill-formed.
6961+
6962+
\pnum
6963+
\returns \tcode{p}.
6964+
\end{itemdescr}
6965+
69066966
\rSec2[util.dynamic.safety]{Pointer safety}
69076967

69086968
\pnum

0 commit comments

Comments
 (0)