Changeset 9c9ee5d in mainline
- Timestamp:
- 2018-07-05T21:41:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6175b78
- Parents:
- f6f636f
- git-author:
- Dzejrou <dzejrou@…> (2018-05-12 21:01:13)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
- Location:
- uspace/lib/cpp/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/tuple.hpp
rf6f636f r9c9ee5d 81 81 template<class... Tuples> 82 82 constexpr aux::tuple_cat_type_t<Tuples...> tuple_cat(Tuples&&... tpls) 83 { 83 { // TODO: currently does not work because of index mismatch 84 84 return aux::tuple_cat( 85 85 forward<Tuples>(tpls)..., … … 206 206 : tuple_element_wrapper<Is, Ts>(forward<Us>(us))... 207 207 { /* DUMMY BODY */ } 208 209 template<class... Us> 210 constexpr tuple_impl(const tuple<Us...>& tpl) 211 : tuple_impl{tpl, make_index_sequence<sizeof...(Us)>{}} 212 { /* DUMMY BODY */ } 213 214 template<class... Us> 215 constexpr tuple_impl(tuple<Us...>&& tpl) 216 : tuple_impl{move<tuple<Us...>>(tpl), make_index_sequence<sizeof...(Us)>{}} 217 { /* DUMMY BODY */ } 218 219 template<class... Us, size_t... Iss> 220 constexpr tuple_impl(const tuple<Us...>& tpl, index_sequence<Iss...>) 221 : tuple_impl{get<Iss>(tpl)...} 222 { /* DUMMY BODY */ } 223 224 template<class... Us, size_t... Iss> 225 constexpr tuple_impl(tuple<Us...>&& tpl, index_sequence<Iss...>) 226 : tuple_impl{get<Iss>(move(tpl))...} 227 { /* DUMMY BODY */ } 208 228 }; 209 229 … … 313 333 { /* DUMMY BODY */ } 314 334 315 template<class... Us> 316 constexpr explicit tuple(Us&&... us )335 template<class... Us> // TODO: is_convertible == true for all Us to all Ts 336 constexpr explicit tuple(Us&&... us, enable_if_t<sizeof...(Us) == sizeof...(Ts)>* = nullptr) 317 337 : base_t(forward<Us>(us)...) 318 338 { /* DUMMY BODY */ } … … 322 342 323 343 template<class... Us> 324 constexpr tuple(const tuple<Us...>& tpl )344 constexpr tuple(const tuple<Us...>& tpl, enable_if_t<sizeof...(Us) == sizeof...(Ts)>* = nullptr) 325 345 : base_t(tpl) 326 346 { /* DUMMY BODY */ } 327 347 328 348 template<class... Us> 329 constexpr tuple(tuple<Us...>&& tpl )330 : base_t( forward<tuple<Us>>(tpl)...)349 constexpr tuple(tuple<Us...>&& tpl, enable_if_t<sizeof...(Us) == sizeof...(Ts)>* = nullptr) 350 : base_t(move(tpl)) 331 351 { /* DUMMY BODY */ } 332 352 … … 356 376 tuple& operator=(const tuple& other) 357 377 { 358 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign (*this, other);378 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign_copy(*this, other); 359 379 360 380 return *this; … … 363 383 tuple& operator=(tuple&& other) noexcept(aux::tuple_noexcept_assignment<Ts...>::value) 364 384 { 365 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign (*this, forward<tuple>(other));385 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign_move(*this, move(other)); 366 386 367 387 return *this; … … 371 391 tuple& operator=(const tuple<Us...>& other) 372 392 { 373 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign (*this, other);393 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign_copy(*this, other); 374 394 375 395 return *this; … … 379 399 tuple& operator=(tuple<Us...>&& other) 380 400 { 381 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign (*this, forward<Us>(other)...);401 aux::tuple_ops<0, sizeof...(Ts) - 1>::assign_move(*this, move(other)); 382 402 383 403 return *this; … … 389 409 get<0>(*this) = p.first; 390 410 get<1>(*this) = p.second; 411 412 return *this; 391 413 } 392 414 … … 396 418 get<0>(*this) = forward<U1>(p.first); 397 419 get<1>(*this) = forward<U2>(p.second); 420 421 return *this; 398 422 } 399 423 -
uspace/lib/cpp/include/internal/tuple/tuple_ops.hpp
rf6f636f r9c9ee5d 50 50 { 51 51 template<class T, class U> 52 static void assign (T&& lhs, U&& rhs)52 static void assign_copy(T& lhs, const U& rhs) 53 53 { 54 get<I>( forward<T>(lhs)) = get<I>(forward<U>(rhs));54 get<I>(lhs) = get<I>(rhs); 55 55 56 tuple_ops<I + 1, N>::assign(forward<T>(lhs), forward<U>(rhs)); 56 tuple_ops<I + 1, N>::assign_copy(lhs, rhs); 57 } 58 59 template<class T, class U> 60 static void assign_move(T& lhs, U&& rhs) 61 { 62 get<I>(lhs) = move(get<I>(rhs)); 63 64 tuple_ops<I + 1, N>::assign_move(lhs, move(rhs)); 57 65 } 58 66 … … 83 91 { 84 92 template<class T, class U> 85 static void assign (T&& lhs, U&& rhs)93 static void assign_copy(T& lhs, const U& rhs) 86 94 { 87 get<N>(forward<T>(lhs)) = get<N>(forward<U>(rhs)); 95 get<N>(lhs) = get<N>(rhs); 96 } 97 98 template<class T, class U> 99 static void assign_move(T& lhs, U&& rhs) 100 { 101 get<N>(lhs) = move(get<N>(rhs)); 88 102 } 89 103
Note:
See TracChangeset
for help on using the changeset viewer.