Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:34:58

0001 /*=============================================================================
0002     Copyright (c) 2014-2015 Kohei Takahashi
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #ifndef FUSION_TUPLE_14122014_0102
0008 #define FUSION_TUPLE_14122014_0102
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/tuple/tuple_fwd.hpp>
0012 
0013 ///////////////////////////////////////////////////////////////////////////////
0014 // With no variadics, we will use the C++03 version
0015 ///////////////////////////////////////////////////////////////////////////////
0016 #if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
0017 # include <boost/fusion/tuple/detail/tuple.hpp>
0018 #else
0019 
0020 ///////////////////////////////////////////////////////////////////////////////
0021 // C++11 interface
0022 ///////////////////////////////////////////////////////////////////////////////
0023 #include <boost/core/enable_if.hpp>
0024 #include <boost/fusion/container/vector/vector.hpp>
0025 #include <boost/fusion/sequence/intrinsic/size.hpp>
0026 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
0027 #include <boost/fusion/sequence/intrinsic/at.hpp>
0028 #include <boost/fusion/sequence/comparison.hpp>
0029 #include <boost/fusion/sequence/io.hpp>
0030 #include <boost/fusion/support/detail/and.hpp>
0031 #include <boost/type_traits/is_convertible.hpp>
0032 #include <utility>
0033 
0034 namespace boost { namespace fusion
0035 {
0036     template <typename ...T>
0037     struct tuple
0038         : vector_detail::vector_data<
0039               typename detail::make_index_sequence<sizeof...(T)>::type
0040             , T...
0041           >
0042     {
0043         typedef vector_detail::vector_data<
0044             typename detail::make_index_sequence<sizeof...(T)>::type
0045           , T...
0046         > base;
0047 
0048         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0049         BOOST_DEFAULTED_FUNCTION(tuple(), {})
0050 
0051         template <
0052             typename ...U
0053           , typename = typename boost::enable_if_c<
0054                 sizeof...(U) >= sizeof...(T)
0055             >::type
0056         >
0057         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0058         tuple(tuple<U...> const& other)
0059             : base(vector_detail::each_elem(), other) {}
0060 
0061         template <
0062             typename ...U
0063           , typename = typename boost::enable_if_c<
0064                 sizeof...(U) >= sizeof...(T)
0065             >::type
0066         >
0067         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0068         tuple(tuple<U...>&& other)
0069             : base(vector_detail::each_elem(), std::move(other)) {}
0070 
0071         template <
0072             typename ...U
0073           , typename = typename boost::enable_if_c<(
0074                 fusion::detail::and_<is_convertible<U, T>...>::value &&
0075                 sizeof...(U) >= 1
0076             )>::type
0077         >
0078         /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
0079         explicit
0080         tuple(U&&... args)
0081             : base(vector_detail::each_elem(), std::forward<U>(args)...) {}
0082 
0083         template<typename U1, typename U2>
0084         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0085         tuple(std::pair<U1, U2> const& other)
0086             : base(vector_detail::each_elem(), other.first, other.second) {}
0087 
0088         template<typename U1, typename U2>
0089         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0090         tuple(std::pair<U1, U2>&& other)
0091             : base(vector_detail::each_elem(), std::move(other.first), std::move(other.second)) {}
0092 
0093         template<typename U>
0094         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0095         tuple& operator=(U&& rhs)
0096         {
0097             base::assign_sequence(std::forward<U>(rhs));
0098             return *this;
0099         }
0100     };
0101 
0102     template <typename Tuple>
0103     struct tuple_size : result_of::size<Tuple> {};
0104 
0105     template <int N, typename Tuple>
0106     struct tuple_element : result_of::value_at_c<Tuple, N> {};
0107 
0108     template <int N, typename Tuple>
0109     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0110     inline typename result_of::at_c<Tuple, N>::type
0111     get(Tuple& tup)
0112     {
0113         return at_c<N>(tup);
0114     }
0115 
0116     template <int N, typename Tuple>
0117     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0118     inline typename result_of::at_c<Tuple const, N>::type
0119     get(Tuple const& tup)
0120     {
0121         return at_c<N>(tup);
0122     }
0123 }}
0124 
0125 #endif
0126 #endif
0127