tmp/tmppz6rdx3a/{from.md → to.md}
RENAMED
|
@@ -2,11 +2,13 @@
|
|
| 2 |
|
| 3 |
### General <a id="support.rtti.general">[[support.rtti.general]]</a>
|
| 4 |
|
| 5 |
The header `<typeinfo>` defines a type associated with type information
|
| 6 |
generated by the implementation. It also defines two types for reporting
|
| 7 |
-
dynamic type identification errors.
|
|
|
|
|
|
|
| 8 |
|
| 9 |
### Header `<typeinfo>` synopsis <a id="typeinfo.syn">[[typeinfo.syn]]</a>
|
| 10 |
|
| 11 |
``` cpp
|
| 12 |
// all freestanding
|
|
@@ -27,12 +29,12 @@ namespace std {
|
|
| 27 |
constexpr bool operator==(const type_info& rhs) const noexcept;
|
| 28 |
bool before(const type_info& rhs) const noexcept;
|
| 29 |
size_t hash_code() const noexcept;
|
| 30 |
const char* name() const noexcept;
|
| 31 |
|
| 32 |
-
type_info(const type_info&) = delete;
|
| 33 |
-
type_info& operator=(const type_info&) = delete;
|
| 34 |
};
|
| 35 |
}
|
| 36 |
```
|
| 37 |
|
| 38 |
The class `type_info` describes type information generated by the
|
|
@@ -85,21 +87,21 @@ string [[multibyte.strings]], suitable for conversion and display as a
|
|
| 85 |
``` cpp
|
| 86 |
namespace std {
|
| 87 |
class bad_cast : public exception {
|
| 88 |
public:
|
| 89 |
// see [exception] for the specification of the special member functions
|
| 90 |
-
const char* what() const noexcept override;
|
| 91 |
};
|
| 92 |
}
|
| 93 |
```
|
| 94 |
|
| 95 |
The class `bad_cast` defines the type of objects thrown as exceptions by
|
| 96 |
the implementation to report the execution of an invalid `dynamic_cast`
|
| 97 |
expression [[expr.dynamic.cast]].
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
-
const char* what() const noexcept override;
|
| 101 |
```
|
| 102 |
|
| 103 |
*Returns:* An *implementation-defined* NTBS.
|
| 104 |
|
| 105 |
### Class `bad_typeid` <a id="bad.typeid">[[bad.typeid]]</a>
|
|
@@ -107,20 +109,129 @@ const char* what() const noexcept override;
|
|
| 107 |
``` cpp
|
| 108 |
namespace std {
|
| 109 |
class bad_typeid : public exception {
|
| 110 |
public:
|
| 111 |
// see [exception] for the specification of the special member functions
|
| 112 |
-
const char* what() const noexcept override;
|
| 113 |
};
|
| 114 |
}
|
| 115 |
```
|
| 116 |
|
| 117 |
The class `bad_typeid` defines the type of objects thrown as exceptions
|
| 118 |
by the implementation to report a null pointer in a `typeid` expression
|
| 119 |
[[expr.typeid]].
|
| 120 |
|
| 121 |
``` cpp
|
| 122 |
-
const char* what() const noexcept override;
|
| 123 |
```
|
| 124 |
|
| 125 |
*Returns:* An *implementation-defined* NTBS.
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
### General <a id="support.rtti.general">[[support.rtti.general]]</a>
|
| 4 |
|
| 5 |
The header `<typeinfo>` defines a type associated with type information
|
| 6 |
generated by the implementation. It also defines two types for reporting
|
| 7 |
+
dynamic type identification errors. The header `<typeindex>` defines a
|
| 8 |
+
wrapper type for use as an index type in associative containers
|
| 9 |
+
[[associative]] and in unordered associative containers [[unord]].
|
| 10 |
|
| 11 |
### Header `<typeinfo>` synopsis <a id="typeinfo.syn">[[typeinfo.syn]]</a>
|
| 12 |
|
| 13 |
``` cpp
|
| 14 |
// all freestanding
|
|
|
|
| 29 |
constexpr bool operator==(const type_info& rhs) const noexcept;
|
| 30 |
bool before(const type_info& rhs) const noexcept;
|
| 31 |
size_t hash_code() const noexcept;
|
| 32 |
const char* name() const noexcept;
|
| 33 |
|
| 34 |
+
type_info(const type_info&) = delete;
|
| 35 |
+
type_info& operator=(const type_info&) = delete;
|
| 36 |
};
|
| 37 |
}
|
| 38 |
```
|
| 39 |
|
| 40 |
The class `type_info` describes type information generated by the
|
|
|
|
| 87 |
``` cpp
|
| 88 |
namespace std {
|
| 89 |
class bad_cast : public exception {
|
| 90 |
public:
|
| 91 |
// see [exception] for the specification of the special member functions
|
| 92 |
+
constexpr const char* what() const noexcept override;
|
| 93 |
};
|
| 94 |
}
|
| 95 |
```
|
| 96 |
|
| 97 |
The class `bad_cast` defines the type of objects thrown as exceptions by
|
| 98 |
the implementation to report the execution of an invalid `dynamic_cast`
|
| 99 |
expression [[expr.dynamic.cast]].
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
+
constexpr const char* what() const noexcept override;
|
| 103 |
```
|
| 104 |
|
| 105 |
*Returns:* An *implementation-defined* NTBS.
|
| 106 |
|
| 107 |
### Class `bad_typeid` <a id="bad.typeid">[[bad.typeid]]</a>
|
|
|
|
| 109 |
``` cpp
|
| 110 |
namespace std {
|
| 111 |
class bad_typeid : public exception {
|
| 112 |
public:
|
| 113 |
// see [exception] for the specification of the special member functions
|
| 114 |
+
constexpr const char* what() const noexcept override;
|
| 115 |
};
|
| 116 |
}
|
| 117 |
```
|
| 118 |
|
| 119 |
The class `bad_typeid` defines the type of objects thrown as exceptions
|
| 120 |
by the implementation to report a null pointer in a `typeid` expression
|
| 121 |
[[expr.typeid]].
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
+
constexpr const char* what() const noexcept override;
|
| 125 |
```
|
| 126 |
|
| 127 |
*Returns:* An *implementation-defined* NTBS.
|
| 128 |
|
| 129 |
+
### Header `<typeindex>` synopsis <a id="type.index.synopsis">[[type.index.synopsis]]</a>
|
| 130 |
+
|
| 131 |
+
``` cpp
|
| 132 |
+
#include <compare> // see [compare.syn]
|
| 133 |
+
|
| 134 |
+
namespace std {
|
| 135 |
+
class type_index;
|
| 136 |
+
template<class T> struct hash;
|
| 137 |
+
template<> struct hash<type_index>;
|
| 138 |
+
}
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
### Class `type_index` <a id="type.index">[[type.index]]</a>
|
| 142 |
+
|
| 143 |
+
``` cpp
|
| 144 |
+
namespace std {
|
| 145 |
+
class type_index {
|
| 146 |
+
public:
|
| 147 |
+
type_index(const type_info& rhs) noexcept;
|
| 148 |
+
bool operator==(const type_index& rhs) const noexcept;
|
| 149 |
+
bool operator< (const type_index& rhs) const noexcept;
|
| 150 |
+
bool operator> (const type_index& rhs) const noexcept;
|
| 151 |
+
bool operator<=(const type_index& rhs) const noexcept;
|
| 152 |
+
bool operator>=(const type_index& rhs) const noexcept;
|
| 153 |
+
strong_ordering operator<=>(const type_index& rhs) const noexcept;
|
| 154 |
+
size_t hash_code() const noexcept;
|
| 155 |
+
const char* name() const noexcept;
|
| 156 |
+
|
| 157 |
+
private:
|
| 158 |
+
const type_info* target; // exposition only
|
| 159 |
+
// Note that the use of a pointer here, rather than a reference,
|
| 160 |
+
// means that the default copy/move constructor and assignment
|
| 161 |
+
// operators will be provided and work as expected.
|
| 162 |
+
};
|
| 163 |
+
}
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
The class `type_index` provides a simple wrapper for `type_info` which
|
| 167 |
+
can be used as an index type in associative containers [[associative]]
|
| 168 |
+
and in unordered associative containers [[unord]].
|
| 169 |
+
|
| 170 |
+
``` cpp
|
| 171 |
+
type_index(const type_info& rhs) noexcept;
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
*Effects:* Constructs a `type_index` object, the equivalent of
|
| 175 |
+
`target = &rhs`.
|
| 176 |
+
|
| 177 |
+
``` cpp
|
| 178 |
+
bool operator==(const type_index& rhs) const noexcept;
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
*Returns:* `*target == *rhs.target`.
|
| 182 |
+
|
| 183 |
+
``` cpp
|
| 184 |
+
bool operator<(const type_index& rhs) const noexcept;
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
*Returns:* `target->before(*rhs.target)`.
|
| 188 |
+
|
| 189 |
+
``` cpp
|
| 190 |
+
bool operator>(const type_index& rhs) const noexcept;
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
*Returns:* `rhs.target->before(*target)`.
|
| 194 |
+
|
| 195 |
+
``` cpp
|
| 196 |
+
bool operator<=(const type_index& rhs) const noexcept;
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
*Returns:* `!rhs.target->before(*target)`.
|
| 200 |
+
|
| 201 |
+
``` cpp
|
| 202 |
+
bool operator>=(const type_index& rhs) const noexcept;
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
*Returns:* `!target->before(*rhs.target)`.
|
| 206 |
+
|
| 207 |
+
``` cpp
|
| 208 |
+
strong_ordering operator<=>(const type_index& rhs) const noexcept;
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
*Effects:* Equivalent to:
|
| 212 |
+
|
| 213 |
+
``` cpp
|
| 214 |
+
if (*target == *rhs.target) return strong_ordering::equal;
|
| 215 |
+
if (target->before(*rhs.target)) return strong_ordering::less;
|
| 216 |
+
return strong_ordering::greater;
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
``` cpp
|
| 220 |
+
size_t hash_code() const noexcept;
|
| 221 |
+
```
|
| 222 |
+
|
| 223 |
+
*Returns:* `target->hash_code()`.
|
| 224 |
+
|
| 225 |
+
``` cpp
|
| 226 |
+
const char* name() const noexcept;
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
*Returns:* `target->name()`.
|
| 230 |
+
|
| 231 |
+
``` cpp
|
| 232 |
+
template<> struct hash<type_index>;
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
For an object `index` of type `type_index`, `hash<type_index>()(index)`
|
| 236 |
+
shall evaluate to the same result as `index.hash_code()`.
|
| 237 |
+
|