tmp/tmpoz0fpkt6/{from.md → to.md}
RENAMED
|
@@ -6,108 +6,129 @@ namespace std {
|
|
| 6 |
public:
|
| 7 |
// types
|
| 8 |
using type = T;
|
| 9 |
|
| 10 |
// construct/copy/destroy
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 14 |
|
| 15 |
// assignment
|
| 16 |
-
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 17 |
|
| 18 |
// access
|
| 19 |
-
operator T& () const noexcept;
|
| 20 |
-
T& get() const noexcept;
|
| 21 |
|
| 22 |
// invocation
|
| 23 |
template<class... ArgTypes>
|
| 24 |
-
invoke_result_t<T&, ArgTypes...>
|
| 25 |
-
operator() (ArgTypes&&...) const;
|
| 26 |
};
|
| 27 |
-
|
| 28 |
template<class T>
|
| 29 |
-
reference_wrapper(
|
| 30 |
}
|
| 31 |
```
|
| 32 |
|
| 33 |
-
`reference_wrapper<T>` is a
|
| 34 |
-
wrapper around a reference to an object or
|
|
|
|
| 35 |
|
| 36 |
-
`reference_wrapper<T>`
|
| 37 |
-
[[basic.types]]).
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
-
|
|
|
|
| 43 |
```
|
| 44 |
|
| 45 |
-
*
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
-
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 50 |
```
|
| 51 |
|
| 52 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 53 |
reference to `x.get()`.
|
| 54 |
|
| 55 |
-
####
|
| 56 |
|
| 57 |
``` cpp
|
| 58 |
-
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 59 |
```
|
| 60 |
|
| 61 |
-
*
|
| 62 |
|
| 63 |
-
####
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
-
operator T& () const noexcept;
|
| 67 |
```
|
| 68 |
|
| 69 |
*Returns:* The stored reference.
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
-
T& get() const noexcept;
|
| 73 |
```
|
| 74 |
|
| 75 |
*Returns:* The stored reference.
|
| 76 |
|
| 77 |
-
####
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
template<class... ArgTypes>
|
| 81 |
-
invoke_result_t<T&, ArgTypes...>
|
| 82 |
operator()(ArgTypes&&... args) const;
|
| 83 |
```
|
| 84 |
|
|
|
|
|
|
|
| 85 |
*Returns:* *INVOKE*(get(),
|
| 86 |
-
std::forward\<ArgTypes\>(args)...).
|
| 87 |
|
| 88 |
-
####
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
-
template
|
| 92 |
```
|
| 93 |
|
| 94 |
*Returns:* `reference_wrapper<T>(t)`.
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
-
template
|
| 98 |
```
|
| 99 |
|
| 100 |
*Returns:* `ref(t.get())`.
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
-
template
|
| 104 |
```
|
| 105 |
|
| 106 |
*Returns:* `reference_wrapper <const T>(t)`.
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
-
template
|
| 110 |
```
|
| 111 |
|
| 112 |
*Returns:* `cref(t.get())`.
|
| 113 |
|
|
|
|
| 6 |
public:
|
| 7 |
// types
|
| 8 |
using type = T;
|
| 9 |
|
| 10 |
// construct/copy/destroy
|
| 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 [[basic.types]].
|
|
|
|
| 36 |
|
| 37 |
+
The template parameter `T` of `reference_wrapper` may be an incomplete
|
| 38 |
+
type.
|
| 39 |
+
|
| 40 |
+
#### Constructors and destructor <a id="refwrap.const">[[refwrap.const]]</a>
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
+
template<class U>
|
| 44 |
+
constexpr reference_wrapper(U&& u) noexcept(see below);
|
| 45 |
```
|
| 46 |
|
| 47 |
+
Let *FUN* denote the exposition-only functions
|
| 48 |
+
|
| 49 |
+
``` cpp
|
| 50 |
+
void FUN(T&) noexcept;
|
| 51 |
+
void FUN(T&&) = delete;
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
*Constraints:* The expression *FUN*(declval\<U\>()) is well-formed and
|
| 55 |
+
`is_same_v<remove_cvref_t<U>, reference_wrapper>` is `false`.
|
| 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 expression inside `noexcept` is equivalent to
|
| 62 |
+
`noexcept(`*`FUN`*`(declval<U>()))`.
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
+
constexpr reference_wrapper(const reference_wrapper& x) noexcept;
|
| 66 |
```
|
| 67 |
|
| 68 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 69 |
reference to `x.get()`.
|
| 70 |
|
| 71 |
+
#### Assignment <a id="refwrap.assign">[[refwrap.assign]]</a>
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
+
constexpr reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 75 |
```
|
| 76 |
|
| 77 |
+
*Ensures:* `*this` stores a reference to `x.get()`.
|
| 78 |
|
| 79 |
+
#### Access <a id="refwrap.access">[[refwrap.access]]</a>
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
+
constexpr operator T& () const noexcept;
|
| 83 |
```
|
| 84 |
|
| 85 |
*Returns:* The stored reference.
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
+
constexpr T& get() const noexcept;
|
| 89 |
```
|
| 90 |
|
| 91 |
*Returns:* The stored reference.
|
| 92 |
|
| 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(),
|
| 104 |
+
std::forward\<ArgTypes\>(args)...). [[func.require]]
|
| 105 |
|
| 106 |
+
#### Helper functions <a id="refwrap.helpers">[[refwrap.helpers]]</a>
|
| 107 |
+
|
| 108 |
+
The template parameter `T` of the following `ref` and `cref` function
|
| 109 |
+
templates may be an incomplete type.
|
| 110 |
|
| 111 |
``` cpp
|
| 112 |
+
template<class T> constexpr reference_wrapper<T> ref(T& t) noexcept;
|
| 113 |
```
|
| 114 |
|
| 115 |
*Returns:* `reference_wrapper<T>(t)`.
|
| 116 |
|
| 117 |
``` cpp
|
| 118 |
+
template<class T> constexpr reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
|
| 119 |
```
|
| 120 |
|
| 121 |
*Returns:* `ref(t.get())`.
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
+
template<class T> constexpr reference_wrapper<const T> cref(const T& t) noexcept;
|
| 125 |
```
|
| 126 |
|
| 127 |
*Returns:* `reference_wrapper <const T>(t)`.
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
+
template<class T> constexpr reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
|
| 131 |
```
|
| 132 |
|
| 133 |
*Returns:* `cref(t.get())`.
|
| 134 |
|