Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:33:20

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003     Copyright (c) 2005 Eric Niebler
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying 
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(FUSION_CONS_07172005_0843)
0009 #define FUSION_CONS_07172005_0843
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/fusion/support/void.hpp>
0013 #include <boost/fusion/support/detail/enabler.hpp>
0014 #include <boost/fusion/container/list/cons_fwd.hpp>
0015 #include <boost/fusion/support/detail/access.hpp>
0016 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0017 #include <boost/fusion/sequence/intrinsic/end.hpp>
0018 #include <boost/fusion/iterator/next.hpp>
0019 #include <boost/fusion/iterator/deref.hpp>
0020 #include <boost/fusion/container/list/nil.hpp>
0021 #include <boost/fusion/container/list/cons_iterator.hpp>
0022 #include <boost/fusion/container/list/detail/begin_impl.hpp>
0023 #include <boost/fusion/container/list/detail/end_impl.hpp>
0024 #include <boost/fusion/container/list/detail/at_impl.hpp>
0025 #include <boost/fusion/container/list/detail/value_at_impl.hpp>
0026 #include <boost/fusion/container/list/detail/empty_impl.hpp>
0027 #include <boost/type_traits/is_convertible.hpp>
0028 #include <boost/type_traits/is_base_of.hpp>
0029 #include <boost/utility/enable_if.hpp>
0030 #include <boost/fusion/support/sequence_base.hpp>
0031 #include <boost/fusion/support/is_sequence.hpp>
0032 #include <boost/mpl/int.hpp>
0033 #include <boost/mpl/bool.hpp>
0034 #include <boost/mpl/and.hpp>
0035 #include <boost/mpl/not.hpp>
0036 
0037 namespace boost { namespace fusion
0038 {
0039     struct cons_tag;
0040     struct forward_traversal_tag;
0041     struct fusion_sequence_tag;
0042 
0043     template <typename Car, typename Cdr /*= nil_*/>
0044     struct cons : sequence_base<cons<Car, Cdr> >
0045     {
0046         typedef mpl::int_<Cdr::size::value+1> size;
0047         typedef cons_tag fusion_tag;
0048         typedef fusion_sequence_tag tag; // this gets picked up by MPL
0049         typedef mpl::false_ is_view;
0050         typedef forward_traversal_tag category;
0051         typedef Car car_type;
0052         typedef Cdr cdr_type;
0053 
0054         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0055         cons()
0056             : car(), cdr() {}
0057 
0058         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0059         explicit cons(typename detail::call_param<Car>::type in_car)
0060             : car(in_car), cdr() {}
0061 
0062         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0063         cons(
0064             typename detail::call_param<Car>::type in_car
0065           , typename detail::call_param<Cdr>::type in_cdr)
0066             : car(in_car), cdr(in_cdr) {}
0067         
0068         template <typename Car2, typename Cdr2>
0069         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0070         cons(cons<Car2, Cdr2> const& rhs)
0071             : car(rhs.car), cdr(rhs.cdr) {}
0072 
0073 #if BOOST_WORKAROUND(BOOST_GCC, / 100 == 406) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0074         // Workaround for `array used as initializer` compile error on gcc 4.6 w/ c++0x.
0075         template <typename = void>
0076 #endif
0077         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0078         cons(cons const& rhs)
0079             : car(rhs.car), cdr(rhs.cdr) {}
0080 
0081         template <typename Sequence>
0082         BOOST_FUSION_GPU_ENABLED
0083         cons(
0084             Sequence const& seq
0085           , typename boost::enable_if<
0086                 mpl::and_<
0087                     traits::is_sequence<Sequence>
0088                   , mpl::not_<is_base_of<cons, Sequence> >
0089                   , mpl::not_<is_convertible<Sequence, Car> > > // use copy to car instead
0090               , detail::enabler_
0091             >::type = detail::enabler
0092         )
0093             : car(*fusion::begin(seq))
0094             , cdr(fusion::next(fusion::begin(seq)), mpl::true_()) {}
0095 
0096         template <typename Iterator>
0097         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0098         cons(Iterator const& iter, mpl::true_ /*this_is_an_iterator*/)
0099             : car(*iter)
0100             , cdr(fusion::next(iter), mpl::true_()) {}
0101 
0102         template <typename Car2, typename Cdr2>
0103         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0104         cons& operator=(cons<Car2, Cdr2> const& rhs)
0105         {
0106             car = rhs.car;
0107             cdr = rhs.cdr;
0108             return *this;
0109         }
0110 
0111         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0112         cons& operator=(cons const& rhs)
0113         {
0114             car = rhs.car;
0115             cdr = rhs.cdr;
0116             return *this;
0117         }
0118 
0119         template <typename Sequence>
0120         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0121         typename boost::enable_if<
0122             mpl::and_<
0123                 traits::is_sequence<Sequence>
0124               , mpl::not_<is_convertible<Sequence, Car> > >
0125           , cons&>::type
0126         operator=(Sequence const& seq)
0127         {
0128             typedef typename result_of::begin<Sequence const>::type Iterator;
0129             Iterator iter = fusion::begin(seq);
0130             this->assign_from_iter(iter);
0131             return *this;
0132         }
0133 
0134         template <typename Iterator>
0135         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0136         void assign_from_iter(Iterator const& iter)
0137         {
0138             car = *iter;
0139             cdr.assign_from_iter(fusion::next(iter));
0140         }
0141 
0142         car_type car;
0143         cdr_type cdr;
0144     };
0145 }}
0146 
0147 #endif
0148