Changeset 016d86e 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:
- 41bd6ec
- Parents:
- 82d256e
- git-author:
- Dzejrou <dzejrou@…> (2018-04-24 16:58:29)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/utility.hpp
r82d256e r016d86e 279 279 */ 280 280 281 // TODO: implement 281 template<class> 282 struct tuple_size; 283 284 template<class T1, class T2> 285 struct tuple_size<pair<T1, T2>> 286 : integral_constant<size_t, 2> 287 { /* DUMMY BODY */ }; 288 289 template<size_t, class> 290 struct tuple_element; 291 292 template<class T1, class T2> 293 struct tuple_element<0, pair<T1, T2>> 294 : aux::type_is<T1> 295 { /* DUMMY BODY */ }; 296 297 template<class T1, class T2> 298 struct tuple_element<1, pair<T1, T2>> 299 : aux::type_is<T2> 300 { /* DUMMY BODY */ }; 301 302 template<size_t I, class T> 303 using tuple_element_t = typename tuple_element<I, T>::type; 304 305 template<size_t I, class T1, class T2> 306 constexpr tuple_element_t<I, pair<T1, T2>>& 307 get(pair<T1, T2>& p) noexcept 308 { 309 if constexpr (I == 0) 310 return p.first; 311 else 312 return p.second; 313 } 314 315 template<size_t I, class T1, class T2> 316 constexpr const tuple_element_t<I, pair<T1, T2>>& 317 get(const pair<T1, T2>& p) noexcept 318 { 319 if constexpr (I == 0) 320 return p.first; 321 else 322 return p.second; 323 } 324 325 template<size_t I, class T1, class T2> 326 constexpr tuple_element_t<I, pair<T1, T2>>&& 327 get(pair<T1, T2>&& p) noexcept 328 { 329 if constexpr (I == 0) 330 return forward<T1>(p.first); 331 else 332 return forward<T2>(p.second); 333 } 334 335 template<class T, class U> 336 constexpr T& get(pair<T, U>& p) noexcept 337 { 338 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 339 340 return get<0>(p); 341 } 342 343 template<class T, class U> 344 constexpr const T& get(const pair<T, U>& p) noexcept 345 { 346 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 347 348 return get<0>(p); 349 } 350 351 template<class T, class U> 352 constexpr T&& get(pair<T, U>&& p) noexcept 353 { 354 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 355 356 return get<0>(move(p)); 357 } 358 359 template<class T, class U> 360 constexpr T& get(pair<U, T>& p) noexcept 361 { 362 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 363 364 return get<1>(p); 365 } 366 367 template<class T, class U> 368 constexpr const T& get(const pair<U, T>& p) noexcept 369 { 370 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 371 372 return get<1>(p); 373 } 374 375 template<class T, class U> 376 constexpr T&& get(pair<U, T>&& p) noexcept 377 { 378 static_assert(!is_same_v<T, U>, "get(pair) requires distinct types"); 379 380 return get<1>(move(p)); 381 } 282 382 283 383 /**
Note:
See TracChangeset
for help on using the changeset viewer.