BVB Source Codes

mars Show tuple.hpp Source code

Return Download mars: download tuple.hpp Source code - Download mars Source code - Type:.hpp
  1.  
  2. //          Copyright Oliver Kowalke 2014.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //    (See accompanying file LICENSE_1_0.txt or copy at
  5. //          http://www.boost.org/LICENSE_1_0.txt)
  6.  
  7. #ifndef BOOST_CONTEXT_DETAIL_TUPLE_H
  8. #define BOOST_CONTEXT_DETAIL_TUPLE_H
  9.  
  10. #include <tuple>
  11. #include <utility>
  12.  
  13. #include <boost/config.hpp>
  14.  
  15. #include <boost/context/detail/config.hpp>
  16. #include <boost/context/detail/index_sequence.hpp>
  17.  
  18. #ifdef BOOST_HAS_ABI_HEADERS
  19. # include BOOST_ABI_PREFIX
  20. #endif
  21.  
  22. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  23. namespace context {
  24. namespace detail {
  25.  
  26. template< typename ... S, typename ... T, std::size_t ... I >
  27. void
  28. head_impl( std::tuple< S ... > & s,
  29.            std::tuple< T ... > & t, index_sequence< I ... >) {
  30.     t = std::tuple< T ... >{ std::get< I >( s) ... };
  31. }
  32.  
  33. template< typename ... S, typename ... T, std::size_t ... I >
  34. void
  35. head_impl( std::tuple< S ... > && s,
  36.            std::tuple< T ... > & t, index_sequence< I ... >) {
  37.     t = std::tuple< T ... >{ std::get< I >( std::move( s) ) ... };
  38. }
  39.  
  40. template< typename ... S, std::size_t ... I1, typename ... T, std::size_t ... I2 >
  41. void
  42. tail_impl( std::tuple< S ... > & s, index_sequence< I1 ... >,
  43.            std::tuple< T ... > & t, index_sequence< I2 ... >) {
  44.     constexpr std::size_t Idx = (sizeof...(I1)) - (sizeof...(I2));
  45.     t = std::tuple< T ... >{ std::get< (Idx + I2) >( s) ... };
  46. }
  47.  
  48. template< typename ... S, std::size_t ... I1, typename ... T, std::size_t ... I2 >
  49. void
  50. tail_impl( std::tuple< S ... > && s, index_sequence< I1 ... >,
  51.            std::tuple< T ... > & t, index_sequence< I2 ... >) {
  52.     constexpr std::size_t Idx = (sizeof...(I1)) - (sizeof...(I2));
  53.     t = std::tuple< T ... >{ std::get< (Idx + I2) >( std::move( s) ) ... };
  54. }
  55.  
  56. template< typename ... T >
  57. class tuple_head;
  58.  
  59. template< typename ... T >
  60. class tuple_head< std::tuple< T ... > > {
  61. private:
  62.     std::tuple< T ... > &   t_;
  63.  
  64. public:
  65.     tuple_head( std::tuple< T ... > & t) noexcept :
  66.         t_( t) {
  67.     }
  68.  
  69.     template< typename ... S >
  70.     void operator=( std::tuple< S ... > & s) {
  71.         static_assert((sizeof...(T)) <= (sizeof...(S)), "invalid tuple size");
  72.         head_impl( s,
  73.                    t_, index_sequence_for< T ... >{} );
  74.     }
  75.     template< typename ... S >
  76.     void operator=( std::tuple< S ... > && s) {
  77.         static_assert((sizeof...(T)) <= (sizeof...(S)), "invalid tuple size");
  78.         head_impl( std::move( s),
  79.                    t_, index_sequence_for< T ... >{} );
  80.     }
  81. };
  82.  
  83. template< typename ... T >
  84. class tuple_tail;
  85.  
  86. template< typename ... T >
  87. class tuple_tail< std::tuple< T ... > > {
  88. private:
  89.     std::tuple< T ... > &   t_;
  90.  
  91. public:
  92.     tuple_tail( std::tuple< T ... > & t) noexcept :
  93.         t_( t) {
  94.     }
  95.  
  96.     template< typename ... S >
  97.     void operator=( std::tuple< S ... > & s) {
  98.         static_assert((sizeof...(T)) <= (sizeof...(S)), "invalid tuple size");
  99.         tail_impl( s, index_sequence_for< S ... >{},
  100.                    t_, index_sequence_for< T ... >{} );
  101.     }
  102.  
  103.     template< typename ... S >
  104.     void operator=( std::tuple< S ... > && s) {
  105.         static_assert((sizeof...(T)) <= (sizeof...(S)), "invalid tuple size");
  106.         tail_impl( std::move( s), index_sequence_for< S ... >{},
  107.                    t_, index_sequence_for< T ... >{} );
  108.     }
  109. };
  110.  
  111. template< typename ... T >
  112. detail::tuple_head< std::tuple< T ... > >
  113. head( std::tuple< T ... > & tpl) {
  114.     return tuple_head< std::tuple< T ... > >{ tpl };
  115. }
  116.  
  117. template< typename ... T >
  118. detail::tuple_tail< std::tuple< T ... > >
  119. tail( std::tuple< T ... > & tpl) {
  120.     return tuple_tail< std::tuple< T ... > >{ tpl };
  121. }
  122.  
  123. }}}
  124.  
  125. #ifdef BOOST_HAS_ABI_HEADERS
  126. #include BOOST_ABI_SUFFIX
  127. #endif
  128.  
  129. #endif // BOOST_CONTEXT_DETAIL_TUPLE_H
  130.  
downloadtuple.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top