tmp/tmpsrp0_yko/{from.md → to.md}
RENAMED
|
@@ -1,20 +1,16 @@
|
|
| 1 |
### Pointer traits <a id="pointer.traits">[[pointer.traits]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The class template `pointer_traits` supplies a uniform interface to
|
| 4 |
certain attributes of pointer-like types.
|
| 5 |
|
| 6 |
``` cpp
|
| 7 |
namespace std {
|
| 8 |
template<class Ptr> struct pointer_traits {
|
| 9 |
-
|
| 10 |
-
using element_type = see below;
|
| 11 |
-
using difference_type = see below;
|
| 12 |
-
|
| 13 |
-
template<class U> using rebind = see below;
|
| 14 |
-
|
| 15 |
-
static pointer pointer_to(see below r);
|
| 16 |
};
|
| 17 |
|
| 18 |
template<class T> struct pointer_traits<T*> {
|
| 19 |
using pointer = T*;
|
| 20 |
using element_type = T;
|
|
@@ -27,19 +23,49 @@ namespace std {
|
|
| 27 |
}
|
| 28 |
```
|
| 29 |
|
| 30 |
#### Member types <a id="pointer.traits.types">[[pointer.traits.types]]</a>
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
``` cpp
|
| 33 |
using element_type = see below;
|
| 34 |
```
|
| 35 |
|
| 36 |
-
*Type:* `
|
| 37 |
-
valid and denotes a type [[temp.deduct]]; otherwise, `T` if `Ptr` is a
|
| 38 |
-
class template instantiation of the form `SomePointer<T, Args>`, where
|
| 39 |
-
`Args` is zero or more type arguments; otherwise, the specialization is
|
| 40 |
-
ill-formed.
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
using difference_type = see below;
|
| 44 |
```
|
| 45 |
|
|
@@ -77,18 +103,20 @@ second member function returns `addressof(r)`.
|
|
| 77 |
unspecified; otherwise, it is `element_type&`.
|
| 78 |
|
| 79 |
#### Optional members <a id="pointer.traits.optmem">[[pointer.traits.optmem]]</a>
|
| 80 |
|
| 81 |
Specializations of `pointer_traits` may define the member declared in
|
| 82 |
-
this subclause to customize the behavior of the standard library.
|
|
|
|
|
|
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
static element_type* to_address(pointer p) noexcept;
|
| 86 |
```
|
| 87 |
|
| 88 |
*Returns:* A pointer of type `element_type*` that references the same
|
| 89 |
location as the argument `p`.
|
| 90 |
|
| 91 |
-
[*Note 1*: This function
|
| 92 |
-
defined, it customizes the behavior of the non-member function
|
| 93 |
`to_address` [[pointer.conversion]]. — *end note*]
|
| 94 |
|
|
|
|
| 1 |
### Pointer traits <a id="pointer.traits">[[pointer.traits]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="pointer.traits.general">[[pointer.traits.general]]</a>
|
| 4 |
+
|
| 5 |
The class template `pointer_traits` supplies a uniform interface to
|
| 6 |
certain attributes of pointer-like types.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
namespace std {
|
| 10 |
template<class Ptr> struct pointer_traits {
|
| 11 |
+
see below;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
};
|
| 13 |
|
| 14 |
template<class T> struct pointer_traits<T*> {
|
| 15 |
using pointer = T*;
|
| 16 |
using element_type = T;
|
|
|
|
| 23 |
}
|
| 24 |
```
|
| 25 |
|
| 26 |
#### Member types <a id="pointer.traits.types">[[pointer.traits.types]]</a>
|
| 27 |
|
| 28 |
+
The definitions in this subclause make use of the following
|
| 29 |
+
exposition-only class template and concept:
|
| 30 |
+
|
| 31 |
+
``` cpp
|
| 32 |
+
template<class T>
|
| 33 |
+
struct ptr-traits-elem // exposition only
|
| 34 |
+
{ };
|
| 35 |
+
|
| 36 |
+
template<class T> requires requires { typename T::element_type; }
|
| 37 |
+
struct ptr-traits-elem<T>
|
| 38 |
+
{ using type = typename T::element_type; };
|
| 39 |
+
|
| 40 |
+
template<template<class...> class SomePointer, class T, class... Args>
|
| 41 |
+
requires (!requires { typename SomePointer<T, Args...>::element_type; })
|
| 42 |
+
struct ptr-traits-elem<SomePointer<T, Args...>>
|
| 43 |
+
{ using type = T; };
|
| 44 |
+
|
| 45 |
+
template<class Ptr>
|
| 46 |
+
concept has-elem-type = // exposition only
|
| 47 |
+
requires { typename ptr-traits-elem<Ptr>::type; }
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
If `Ptr` satisfies `has-elem-type`, a specialization
|
| 51 |
+
`pointer_traits<Ptr>` generated from the `pointer_traits` primary
|
| 52 |
+
template has the following members as well as those described in
|
| 53 |
+
[[pointer.traits.functions]]; otherwise, such a specialization has no
|
| 54 |
+
members by any of those names.
|
| 55 |
+
|
| 56 |
+
``` cpp
|
| 57 |
+
using pointer = see below;
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
*Type:* `Ptr`.
|
| 61 |
+
|
| 62 |
``` cpp
|
| 63 |
using element_type = see below;
|
| 64 |
```
|
| 65 |
|
| 66 |
+
*Type:* `typename `*`ptr-traits-elem`*`<Ptr>::type`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
using difference_type = see below;
|
| 70 |
```
|
| 71 |
|
|
|
|
| 103 |
unspecified; otherwise, it is `element_type&`.
|
| 104 |
|
| 105 |
#### Optional members <a id="pointer.traits.optmem">[[pointer.traits.optmem]]</a>
|
| 106 |
|
| 107 |
Specializations of `pointer_traits` may define the member declared in
|
| 108 |
+
this subclause to customize the behavior of the standard library. A
|
| 109 |
+
specialization generated from the `pointer_traits` primary template has
|
| 110 |
+
no member by this name.
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
static element_type* to_address(pointer p) noexcept;
|
| 114 |
```
|
| 115 |
|
| 116 |
*Returns:* A pointer of type `element_type*` that references the same
|
| 117 |
location as the argument `p`.
|
| 118 |
|
| 119 |
+
[*Note 1*: This function is intended to be the inverse of `pointer_to`.
|
| 120 |
+
If defined, it customizes the behavior of the non-member function
|
| 121 |
`to_address` [[pointer.conversion]]. — *end note*]
|
| 122 |
|