Changeset 3d6f7f3 in mainline
- Timestamp:
- 2018-07-05T21:41:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4a7e47b
- Parents:
- 921174c
- git-author:
- Dzejrou <dzejrou@…> (2018-04-22 15:47:11)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- Location:
- uspace/lib/cpp/include
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/tuple.hpp
r921174c r3d6f7f3 31 31 32 32 #include <internal/aux.hpp> 33 #include <internal/tuple_cat.hpp> 34 #include <internal/tuple_ops.hpp> 33 35 #include <functional> 34 36 #include <type_traits> … … 93 95 } 94 96 95 template<class... Tuples> // TODO: dafuq is ctypes? 96 constexpr tuple<Tuples...> tuple_cat(Tuples&&... tpls); 97 template<class... Tuples> 98 constexpr aux::tuple_cat_type_t<Tuples...> tuple_cat(Tuples&&... tpls) 99 { 100 return aux::tuple_cat( 101 forward<Tuples>(tpls)..., 102 make_index_sequence<sizeof...(Tuples)>{}, 103 aux::generate_indices_t<Tuples...>{} 104 ); 105 } 97 106 98 107 /** … … 180 189 constexpr tuple_element_wrapper() = default; 181 190 182 constexpr explicit tuple_element_wrapper(T val) 183 : value{val} 191 constexpr explicit tuple_element_wrapper(T&& val) 192 : value{forward<T>(val)} 193 { /* DUMMY BODY */ } 194 195 template< 196 class U, 197 class = enable_if_t< 198 is_convertible_v<U, T> && !is_same_v<U, T>, 199 void 200 > 201 > 202 constexpr explicit tuple_element_wrapper(U&& val) 203 : value(forward<U>(val)) 184 204 { /* DUMMY BODY */ } 185 205 … … 198 218 { /* DUMMY BODY */ } 199 219 200 constexpr explicit tuple_impl(const Ts&... ts) 201 : tuple_element_wrapper<Is, Ts>(ts)... 220 constexpr explicit tuple_impl(Ts&&... ts) 221 : tuple_element_wrapper<Is, Ts>(forward<Ts>(ts))... 222 { /* DUMMY BODY */ } 223 224 // TODO: enable only if Us is convertible to Ts and they are not same 225 template<class... Us> 226 constexpr explicit tuple_impl(Us&&... us) 227 : tuple_element_wrapper<Is, Ts>(forward<Us>(us))... 202 228 { /* DUMMY BODY */ } 203 229 }; … … 255 281 return wrapper.value; 256 282 } 257 258 283 259 284 namespace aux … … 286 311 } 287 312 288 namespace aux289 {290 template<size_t I, size_t N>291 struct tuple_ops292 {293 template<class T, class U>294 static void assign(T&& lhs, U&& rhs)295 {296 get<I>(forward<T>(lhs)) = get<I>(forward<U>(rhs));297 298 tuple_ops<I + 1, N>::assign(forward<T>(lhs), forward<U>(rhs));299 }300 301 template<class T, class U>302 static void swap(T& lhs, U& rhs)303 {304 std::swap(get<I>(lhs), get<I>(rhs));305 306 tuple_ops<I + 1, N>::swap(lhs, rhs);307 }308 309 template<class T, class U>310 static bool eq(const T& lhs, const U& rhs)311 {312 return (get<I>(lhs) == get<I>(rhs)) && tuple_ops<I + 1, N>::eq(lhs, rhs);313 }314 315 template<class T, class U>316 static bool lt(const T& lhs, const U& rhs)317 {318 return (get<I>(lhs) < get<I>(rhs)) ||319 (!(get<I>(rhs) < get<I>(lhs)) && tuple_ops<I + 1, N>::lt(lhs, rhs));320 }321 };322 323 template<size_t N>324 struct tuple_ops<N, N>325 {326 template<class T, class U>327 static void assign(T&& lhs, U&& rhs)328 {329 get<N>(forward<T>(lhs)) = get<N>(forward<U>(rhs));330 }331 332 template<class T, class U>333 static void swap(T& lhs, U& rhs)334 {335 std::swap(get<N>(lhs), get<N>(rhs));336 }337 338 template<class T, class U>339 static bool eq(const T& lhs, const U& rhs)340 {341 return get<N>(lhs) == get<N>(rhs);342 }343 344 template<class T, class U>345 static bool lt(const T& lhs, const U& rhs)346 {347 return get<N>(lhs) < get<N>(rhs);348 }349 };350 }351 352 313 /** 353 314 * 20.4.2, class template tuple: 354 315 */ 355 356 316 357 317 template<class... Ts> … … 382 342 tuple(tuple&&) = default; 383 343 384 /* template<class... Us> */385 /* constexpr tuple(const tuple<Us...>& tpl) */386 /* : base_t(tpl) */387 //{ /* DUMMY BODY */ }388 389 /* template<class... Us> */390 /* constexpr tuple(tuple<Us...>& tpl) */391 /* : base_t(forward<tuple<Us>>(tpl)...) */392 //{ /* DUMMY BODY */ }344 template<class... Us> 345 constexpr tuple(const tuple<Us...>& tpl) 346 : base_t(tpl) 347 { /* DUMMY BODY */ } 348 349 template<class... Us> 350 constexpr tuple(tuple<Us...>&& tpl) 351 : base_t(forward<tuple<Us>>(tpl)...) 352 { /* DUMMY BODY */ } 393 353 394 354 // TODO: pair related construction and assignment needs convertibility, not size
Note:
See TracChangeset
for help on using the changeset viewer.