tmp/tmp4t_f662i/{from.md → to.md}
RENAMED
|
@@ -1,45 +1,50 @@
|
|
| 1 |
### Class template `reference_wrapper` <a id="refwrap">[[refwrap]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template<class T> class reference_wrapper {
|
| 6 |
public:
|
| 7 |
// types
|
| 8 |
using type = T;
|
| 9 |
|
| 10 |
-
//
|
| 11 |
template<class U>
|
| 12 |
constexpr reference_wrapper(U&&) noexcept(see below);
|
| 13 |
constexpr reference_wrapper(const reference_wrapper& x) noexcept;
|
| 14 |
|
| 15 |
-
// assignment
|
| 16 |
constexpr reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 17 |
|
| 18 |
-
// access
|
| 19 |
constexpr operator T& () const noexcept;
|
| 20 |
constexpr T& get() const noexcept;
|
| 21 |
|
| 22 |
-
// invocation
|
| 23 |
template<class... ArgTypes>
|
| 24 |
-
constexpr invoke_result_t<T&, ArgTypes...> operator()(ArgTypes&&...) const
|
|
|
|
| 25 |
};
|
|
|
|
| 26 |
template<class T>
|
| 27 |
reference_wrapper(T&) -> reference_wrapper<T>;
|
| 28 |
}
|
| 29 |
```
|
| 30 |
|
| 31 |
`reference_wrapper<T>` is a *Cpp17CopyConstructible* and
|
| 32 |
*Cpp17CopyAssignable* wrapper around a reference to an object or
|
| 33 |
function of type `T`.
|
| 34 |
|
| 35 |
-
`reference_wrapper<T>` is a trivially copyable type
|
|
|
|
| 36 |
|
| 37 |
The template parameter `T` of `reference_wrapper` may be an incomplete
|
| 38 |
type.
|
| 39 |
|
| 40 |
-
#### Constructors
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
template<class U>
|
| 44 |
constexpr reference_wrapper(U&& u) noexcept(see below);
|
| 45 |
```
|
|
@@ -56,11 +61,11 @@ void FUN(T&&) = delete;
|
|
| 56 |
|
| 57 |
*Effects:* Creates a variable `r` as if by `T& r = std::forward<U>(u)`,
|
| 58 |
then constructs a `reference_wrapper` object that stores a reference to
|
| 59 |
`r`.
|
| 60 |
|
| 61 |
-
*Remarks:* The
|
| 62 |
`noexcept(`*`FUN`*`(declval<U>()))`.
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
constexpr reference_wrapper(const reference_wrapper& x) noexcept;
|
| 66 |
```
|
|
@@ -93,11 +98,11 @@ constexpr T& get() const noexcept;
|
|
| 93 |
#### Invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 94 |
|
| 95 |
``` cpp
|
| 96 |
template<class... ArgTypes>
|
| 97 |
constexpr invoke_result_t<T&, ArgTypes...>
|
| 98 |
-
operator()(ArgTypes&&... args) const;
|
| 99 |
```
|
| 100 |
|
| 101 |
*Mandates:* `T` is a complete type.
|
| 102 |
|
| 103 |
*Returns:* *INVOKE*(get(),
|
|
@@ -116,11 +121,11 @@ template<class T> constexpr reference_wrapper<T> ref(T& t) noexcept;
|
|
| 116 |
|
| 117 |
``` cpp
|
| 118 |
template<class T> constexpr reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
|
| 119 |
```
|
| 120 |
|
| 121 |
-
*Returns:* `
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
template<class T> constexpr reference_wrapper<const T> cref(const T& t) noexcept;
|
| 125 |
```
|
| 126 |
|
|
@@ -128,7 +133,39 @@ template<class T> constexpr reference_wrapper<const T> cref(const T& t) noexcept
|
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
template<class T> constexpr reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
|
| 131 |
```
|
| 132 |
|
| 133 |
-
*Returns:* `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
|
|
|
| 1 |
### Class template `reference_wrapper` <a id="refwrap">[[refwrap]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="refwrap.general">[[refwrap.general]]</a>
|
| 4 |
+
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
template<class T> class reference_wrapper {
|
| 8 |
public:
|
| 9 |
// types
|
| 10 |
using type = T;
|
| 11 |
|
| 12 |
+
// [refwrap.const], constructors
|
| 13 |
template<class U>
|
| 14 |
constexpr reference_wrapper(U&&) noexcept(see below);
|
| 15 |
constexpr reference_wrapper(const reference_wrapper& x) noexcept;
|
| 16 |
|
| 17 |
+
// [refwrap.assign], assignment
|
| 18 |
constexpr reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 19 |
|
| 20 |
+
// [refwrap.access], access
|
| 21 |
constexpr operator T& () const noexcept;
|
| 22 |
constexpr T& get() const noexcept;
|
| 23 |
|
| 24 |
+
// [refwrap.invoke], invocation
|
| 25 |
template<class... ArgTypes>
|
| 26 |
+
constexpr invoke_result_t<T&, ArgTypes...> operator()(ArgTypes&&...) const
|
| 27 |
+
noexcept(is_nothrow_invocable_v<T&, ArgTypes...>);
|
| 28 |
};
|
| 29 |
+
|
| 30 |
template<class T>
|
| 31 |
reference_wrapper(T&) -> reference_wrapper<T>;
|
| 32 |
}
|
| 33 |
```
|
| 34 |
|
| 35 |
`reference_wrapper<T>` is a *Cpp17CopyConstructible* and
|
| 36 |
*Cpp17CopyAssignable* wrapper around a reference to an object or
|
| 37 |
function of type `T`.
|
| 38 |
|
| 39 |
+
`reference_wrapper<T>` is a trivially copyable type
|
| 40 |
+
[[term.trivially.copyable.type]].
|
| 41 |
|
| 42 |
The template parameter `T` of `reference_wrapper` may be an incomplete
|
| 43 |
type.
|
| 44 |
|
| 45 |
+
#### Constructors <a id="refwrap.const">[[refwrap.const]]</a>
|
| 46 |
|
| 47 |
``` cpp
|
| 48 |
template<class U>
|
| 49 |
constexpr reference_wrapper(U&& u) noexcept(see below);
|
| 50 |
```
|
|
|
|
| 61 |
|
| 62 |
*Effects:* Creates a variable `r` as if by `T& r = std::forward<U>(u)`,
|
| 63 |
then constructs a `reference_wrapper` object that stores a reference to
|
| 64 |
`r`.
|
| 65 |
|
| 66 |
+
*Remarks:* The exception specification is equivalent to
|
| 67 |
`noexcept(`*`FUN`*`(declval<U>()))`.
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
constexpr reference_wrapper(const reference_wrapper& x) noexcept;
|
| 71 |
```
|
|
|
|
| 98 |
#### Invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
template<class... ArgTypes>
|
| 102 |
constexpr invoke_result_t<T&, ArgTypes...>
|
| 103 |
+
operator()(ArgTypes&&... args) const noexcept(is_nothrow_invocable_v<T&, ArgTypes...>);
|
| 104 |
```
|
| 105 |
|
| 106 |
*Mandates:* `T` is a complete type.
|
| 107 |
|
| 108 |
*Returns:* *INVOKE*(get(),
|
|
|
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
template<class T> constexpr reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
|
| 124 |
```
|
| 125 |
|
| 126 |
+
*Returns:* `t`.
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
template<class T> constexpr reference_wrapper<const T> cref(const T& t) noexcept;
|
| 130 |
```
|
| 131 |
|
|
|
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
template<class T> constexpr reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
|
| 136 |
```
|
| 137 |
|
| 138 |
+
*Returns:* `t`.
|
| 139 |
+
|
| 140 |
+
#### `common_reference` related specializations <a id="refwrap.common.ref">[[refwrap.common.ref]]</a>
|
| 141 |
+
|
| 142 |
+
``` cpp
|
| 143 |
+
namespace std {
|
| 144 |
+
template<class T>
|
| 145 |
+
constexpr bool is-ref-wrapper = false; // exposition only
|
| 146 |
+
|
| 147 |
+
template<class T>
|
| 148 |
+
constexpr bool is-ref-wrapper<reference_wrapper<T>> = true;
|
| 149 |
+
|
| 150 |
+
template<class R, class T, class RQ, class TQ>
|
| 151 |
+
concept ref-wrap-common-reference-exists-with = // exposition only
|
| 152 |
+
is-ref-wrapper<R> &&
|
| 153 |
+
requires { typename common_reference_t<typename R::type&, TQ>; } &&
|
| 154 |
+
convertible_to<RQ, common_reference_t<typename R::type&, TQ>>;
|
| 155 |
+
|
| 156 |
+
template<class R, class T, template<class> class RQual, template<class> class TQual>
|
| 157 |
+
requires (ref-wrap-common-reference-exists-with<R, T, RQual<R>, TQual<T>> &&
|
| 158 |
+
!ref-wrap-common-reference-exists-with<T, R, TQual<T>, RQual<R>>)
|
| 159 |
+
struct basic_common_reference<R, T, RQual, TQual> {
|
| 160 |
+
using type = common_reference_t<typename R::type&, TQual<T>>;
|
| 161 |
+
};
|
| 162 |
+
|
| 163 |
+
template<class T, class R, template<class> class TQual, template<class> class RQual>
|
| 164 |
+
requires (ref-wrap-common-reference-exists-with<R, T, RQual<R>, TQual<T>> &&
|
| 165 |
+
!ref-wrap-common-reference-exists-with<T, R, TQual<T>, RQual<R>>)
|
| 166 |
+
struct basic_common_reference<T, R, TQual, RQual> {
|
| 167 |
+
using type = common_reference_t<typename R::type&, TQual<T>>;
|
| 168 |
+
};
|
| 169 |
+
}
|
| 170 |
+
```
|
| 171 |
|