From Jason Turner

[forward]

Diff to HTML by rtfpessoa

tmp/tmpjdxoe6e_/{from.md → to.md} RENAMED
@@ -3,17 +3,17 @@
3
  The library provides templated helper functions to simplify applying
4
  move semantics to an lvalue and to simplify the implementation of
5
  forwarding functions.
6
 
7
  ``` cpp
8
- template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept;
9
- template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept;
10
  ```
11
 
12
  *Returns:* `static_cast<T&&>(t)`.
13
 
14
- if the second form is instantiated with an lvalue reference type, the
15
  program is ill-formed.
16
 
17
  ``` cpp
18
  template <class T, class A1, class A2>
19
  shared_ptr<T> factory(A1&& a1, A2&& a2) {
@@ -36,14 +36,14 @@ forwarded to `A`’s constructor as an rvalue. In the second call to
36
  `factory`, `A1` is deduced as `int&`, so `i` is forwarded to `A`’s
37
  constructor as an lvalue. In both cases, `A2` is deduced as `double`, so
38
  1.414 is forwarded to `A`’s constructor as an rvalue.
39
 
40
  ``` cpp
41
- template <class T> typename remove_reference<T>::type&& move(T&& t) noexcept;
42
  ```
43
 
44
- *Returns:* `static_cast<typename remove_reference<T>::type&&>(t)`.
45
 
46
  ``` cpp
47
  template <class T, class A1>
48
  shared_ptr<T> factory(A1&& a1) {
49
  return shared_ptr<T>(new T(std::forward<A1>(a1)));
@@ -68,12 +68,12 @@ forwarded as a non-const lvalue. This binds to the constructor
68
  `factory`, because of the call `std::move(a)`, `A1` is deduced as `A`,
69
  so `a` is forwarded as an rvalue. This binds to the constructor
70
  `A(A&&)`, which moves the value from `a`.
71
 
72
  ``` cpp
73
- template <class T> typename conditional<
74
  !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
75
- const T&, T&&>::type move_if_noexcept(T& x) noexcept;
76
  ```
77
 
78
  *Returns:* `std::move(x)`
79
 
 
3
  The library provides templated helper functions to simplify applying
4
  move semantics to an lvalue and to simplify the implementation of
5
  forwarding functions.
6
 
7
  ``` cpp
8
+ template <class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept;
9
+ template <class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
10
  ```
11
 
12
  *Returns:* `static_cast<T&&>(t)`.
13
 
14
+ If the second form is instantiated with an lvalue reference type, the
15
  program is ill-formed.
16
 
17
  ``` cpp
18
  template <class T, class A1, class A2>
19
  shared_ptr<T> factory(A1&& a1, A2&& a2) {
 
36
  `factory`, `A1` is deduced as `int&`, so `i` is forwarded to `A`’s
37
  constructor as an lvalue. In both cases, `A2` is deduced as `double`, so
38
  1.414 is forwarded to `A`’s constructor as an rvalue.
39
 
40
  ``` cpp
41
+ template <class T> constexpr remove_reference_t<T>&& move(T&& t) noexcept;
42
  ```
43
 
44
+ *Returns:* `static_cast<remove_reference_t<T>&&>(t)`.
45
 
46
  ``` cpp
47
  template <class T, class A1>
48
  shared_ptr<T> factory(A1&& a1) {
49
  return shared_ptr<T>(new T(std::forward<A1>(a1)));
 
68
  `factory`, because of the call `std::move(a)`, `A1` is deduced as `A`,
69
  so `a` is forwarded as an rvalue. This binds to the constructor
70
  `A(A&&)`, which moves the value from `a`.
71
 
72
  ``` cpp
73
+ template <class T> constexpr conditional_t<
74
  !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
75
+ const T&, T&&> move_if_noexcept(T& x) noexcept;
76
  ```
77
 
78
  *Returns:* `std::move(x)`
79