|
6492 | 6492 | template <class Ptr> struct pointer_traits;
|
6493 | 6493 | template <class T> struct pointer_traits<T*>;
|
6494 | 6494 |
|
| 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 | + |
6495 | 6501 | // \ref{util.dynamic.safety}, pointer safety
|
6496 | 6502 | enum class pointer_safety { relaxed, preferred, strict };
|
6497 | 6503 | void declare_reachable(void* p);
|
|
6903 | 6909 | function. The second member function returns \tcode{addressof(r)}.
|
6904 | 6910 | \end{itemdescr}
|
6905 | 6911 |
|
| 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 | + |
6906 | 6966 | \rSec2[util.dynamic.safety]{Pointer safety}
|
6907 | 6967 |
|
6908 | 6968 | \pnum
|
|
0 commit comments