Changeset 2084bfcd 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:
- 8ac215d
- Parents:
- bc7ec7c
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-13 17:53:25)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:17)
- Location:
- uspace/lib/cpp/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/utility.hpp
rbc7ec7c r2084bfcd 29 29 #ifndef LIBCPP_UTILITY 30 30 #define LIBCPP_UTILITY 31 32 #include <type_traits> 31 33 32 34 namespace std … … 81 83 82 84 template<class T> 83 inline constexpr remove_reference_t<T>&& move(T&& ) noexcept85 inline constexpr remove_reference_t<T>&& move(T&& t) noexcept 84 86 { 85 87 return static_cast<remove_reference_t<T>&&>(t); -
uspace/lib/cpp/include/utility
rbc7ec7c r2084bfcd 27 27 */ 28 28 29 namespace std 30 { 31 /** 32 * 20.2.1, operators: 33 */ 34 template<typename T> 35 bool operator!=(const T& lhs, const T& rhs) 36 { 37 return !(lhs == rhs); 38 } 39 40 template<typename T> 41 bool operator>(const T& lhs, const T& rhs) 42 { 43 return (rhs < lhs); 44 } 45 46 template<typename T> 47 bool operator<=(const T& lhs, const T& rhs) 48 { 49 return !(rhs < lhs); 50 } 51 52 template<typename T> 53 bool operator>=(const T& lhs, const T& rhs) 54 { 55 return !(lhs < rhs); 56 } 57 58 // TODO: swap 59 // TODO: exchange 60 61 /** 62 * 20.2.4, forward/move helpers: 63 */ 64 65 template<class T> 66 inline constexpr T&& forward(remove_reference_t<T>& t) noexcept 67 { 68 return static_cast<T&&>(t); 69 } 70 71 template<class T> 72 inline constexpr T&& forward(remove_reference_t<T>&& t) noexcept 73 { 74 // TODO: check if t is lvalue reference, if it is, the program 75 // is ill-formed according to the standard 76 return static_cast<T&&>(t); 77 } 78 79 template<class T> 80 inline constexpr remove_reference_t<T>&& move(T&&) noexcept 81 { 82 return static_cast<remove_reference_t<T>&&>(t); 83 } 84 85 /** 86 * 20.2.5, function template declval: 87 * Note: This function only needs declaration, not 88 * implementation. 89 */ 90 91 template<class T> 92 add_rvalue_reference_t<T> declval() noexcept; 93 94 /** 95 * 20.3, pairs: 96 */ 97 98 99 struct piecewise_construct_t 100 { 101 explicit piecewise_construct_t() = default; 102 }; 103 104 template<typename T1, typename T2> 105 struct pair 106 { 107 using first_type = T1; 108 using second_type = T2; 109 110 T1 first; 111 T2 second; 112 113 pair(const pair&) = default; 114 pair(pair&&) = default; 115 116 constexpr pair() 117 : first{}, second{} 118 { /* DUMMY BODY */ } 119 120 constexpr pair(const T1& x, const T2& y) 121 : first{x}, second{y} 122 { /* DUMMY BODY */ } 123 124 template<typename U, typename V> 125 constexpr pair(U&& x, V&& y) 126 : first(x), second(y) 127 { /* DUMMY BODY */ } 128 129 template<typename U, typename V> 130 constexpr pair(const pair<U, V>& other) 131 : first(other.first), second(other.second) 132 { /* DUMMY BODY */ } 133 134 template<typename U, typename V> 135 constexpr pair(pair<U, V>&& other) 136 : first(forward<first_type>(other.first)), 137 second(forward<second_type>(other.second)) 138 { /* DUMMY BODY */ } 139 140 /* TODO: need tuple, piecewise_construct_t 141 template<class... Args1, class... Args2> 142 pair(piecewise_construct_t, tuple<Args1...> first_args, tuple<Args2...> second_args) 143 { 144 // TODO: 145 } 146 */ 147 148 pair& operator=(const pair& other) 149 { 150 first = other.first; 151 second = other.second; 152 153 return *this; 154 } 155 156 template<typename U, typename V> 157 pair& operator=(const pair<U, V>& other) 158 { 159 first = other.first; 160 second = other.second; 161 162 return *this; 163 } 164 165 pair& operator=(pair&& other) noexcept 166 { 167 first = forward<first_type>(other.first); 168 second = forward<second_type>(other.second); 169 170 return *this; 171 } 172 }; 173 } 29 #include <impl/utility.hpp>
Note:
See TracChangeset
for help on using the changeset viewer.