Changeset add816c7 in mainline
- Timestamp:
- 2018-07-05T21:41:17Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e91e0f
- Parents:
- 2841b4f
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-13 19:48:41)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/utility.hpp
r2841b4f radd816c7 62 62 63 63 /** 64 * 20.2.4, forward/move helpers: 65 */ 66 67 template<class T> 68 inline constexpr T&& forward(remove_reference_t<T>& t) noexcept 69 { 70 return static_cast<T&&>(t); 71 } 72 73 template<class T> 74 inline constexpr T&& forward(remove_reference_t<T>&& t) noexcept 75 { 76 // TODO: check if t is lvalue reference, if it is, the program 77 // is ill-formed according to the standard 78 return static_cast<T&&>(t); 79 } 80 81 template<class T> 82 inline constexpr remove_reference_t<T>&& move(T&& t) noexcept 83 { 84 return static_cast<remove_reference_t<T>&&>(t); 85 } 86 87 /** 64 88 * 20.2.2, swap: 65 89 */ … … 70 94 is_nothrow_move_assignable<T>::value) 71 95 { 72 T tmp{ std::move(x)};73 x = std::move(y);74 y = std::move(tmp);96 T tmp{move(x)}; 97 x = move(y); 98 y = move(tmp); 75 99 } 76 100 … … 88 112 T exchange(T& obj, U&& new_val) 89 113 { 90 T old_val = std::move(obj);91 obj = std::forward<U>(new_val);114 T old_val = move(obj); 115 obj = forward<U>(new_val); 92 116 93 117 return old_val; 94 }95 96 /**97 * 20.2.4, forward/move helpers:98 */99 100 template<class T>101 inline constexpr T&& forward(remove_reference_t<T>& t) noexcept102 {103 return static_cast<T&&>(t);104 }105 106 template<class T>107 inline constexpr T&& forward(remove_reference_t<T>&& t) noexcept108 {109 // TODO: check if t is lvalue reference, if it is, the program110 // is ill-formed according to the standard111 return static_cast<T&&>(t);112 }113 114 template<class T>115 inline constexpr remove_reference_t<T>&& move(T&& t) noexcept116 {117 return static_cast<remove_reference_t<T>&&>(t);118 118 } 119 119
Note:
See TracChangeset
for help on using the changeset viewer.