comparison DEPENDENCIES/generic/include/boost/fusion/container/list/cons.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/ 7 ==============================================================================*/
8 #if !defined(FUSION_CONS_07172005_0843) 8 #if !defined(FUSION_CONS_07172005_0843)
9 #define FUSION_CONS_07172005_0843 9 #define FUSION_CONS_07172005_0843
10 10
11 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/container/list/cons_fwd.hpp> 12 #include <boost/fusion/container/list/cons_fwd.hpp>
12 #include <boost/fusion/support/detail/access.hpp> 13 #include <boost/fusion/support/detail/access.hpp>
13 #include <boost/fusion/sequence/intrinsic/begin.hpp> 14 #include <boost/fusion/sequence/intrinsic/begin.hpp>
14 #include <boost/fusion/sequence/intrinsic/end.hpp> 15 #include <boost/fusion/sequence/intrinsic/end.hpp>
15 #include <boost/fusion/iterator/next.hpp> 16 #include <boost/fusion/iterator/next.hpp>
16 #include <boost/fusion/iterator/deref.hpp> 17 #include <boost/fusion/iterator/deref.hpp>
18 #include <boost/fusion/container/list/nil.hpp>
17 #include <boost/fusion/container/list/cons_iterator.hpp> 19 #include <boost/fusion/container/list/cons_iterator.hpp>
18 #include <boost/fusion/container/list/detail/begin_impl.hpp> 20 #include <boost/fusion/container/list/detail/begin_impl.hpp>
19 #include <boost/fusion/container/list/detail/end_impl.hpp> 21 #include <boost/fusion/container/list/detail/end_impl.hpp>
20 #include <boost/fusion/container/list/detail/at_impl.hpp> 22 #include <boost/fusion/container/list/detail/at_impl.hpp>
21 #include <boost/fusion/container/list/detail/value_at_impl.hpp> 23 #include <boost/fusion/container/list/detail/value_at_impl.hpp>
22 #include <boost/fusion/container/list/detail/empty_impl.hpp> 24 #include <boost/fusion/container/list/detail/empty_impl.hpp>
23 #include <boost/type_traits/is_convertible.hpp> 25 #include <boost/type_traits/is_convertible.hpp>
24 #include <boost/utility/enable_if.hpp> 26 #include <boost/utility/enable_if.hpp>
25 #include <boost/fusion/support/sequence_base.hpp> 27 #include <boost/fusion/support/sequence_base.hpp>
28 #include <boost/fusion/support/is_sequence.hpp>
26 #include <boost/mpl/int.hpp> 29 #include <boost/mpl/int.hpp>
27 #include <boost/mpl/bool.hpp> 30 #include <boost/mpl/bool.hpp>
28 #include <boost/mpl/or.hpp> 31 #include <boost/mpl/and.hpp>
32 #include <boost/mpl/not.hpp>
29 33
30 namespace boost { namespace fusion 34 namespace boost { namespace fusion
31 { 35 {
32 struct void_; 36 struct void_;
33 struct cons_tag; 37 struct cons_tag;
34 struct forward_traversal_tag; 38 struct forward_traversal_tag;
35 struct fusion_sequence_tag; 39 struct fusion_sequence_tag;
36
37 struct nil_ : sequence_base<nil_>
38 {
39 typedef mpl::int_<0> size;
40 typedef cons_tag fusion_tag;
41 typedef fusion_sequence_tag tag; // this gets picked up by MPL
42 typedef mpl::false_ is_view;
43 typedef forward_traversal_tag category;
44 typedef void_ car_type;
45 typedef void_ cdr_type;
46
47 nil_() {}
48
49 template <typename Iterator>
50 nil_(Iterator const& /*iter*/, mpl::true_ /*this_is_an_iterator*/)
51 {}
52
53 template <typename Iterator>
54 void assign_from_iter(Iterator const& /*iter*/)
55 {
56 }
57 };
58 40
59 template <typename Car, typename Cdr /*= nil_*/> 41 template <typename Car, typename Cdr /*= nil_*/>
60 struct cons : sequence_base<cons<Car, Cdr> > 42 struct cons : sequence_base<cons<Car, Cdr> >
61 { 43 {
62 typedef mpl::int_<Cdr::size::value+1> size; 44 typedef mpl::int_<Cdr::size::value+1> size;
65 typedef mpl::false_ is_view; 47 typedef mpl::false_ is_view;
66 typedef forward_traversal_tag category; 48 typedef forward_traversal_tag category;
67 typedef Car car_type; 49 typedef Car car_type;
68 typedef Cdr cdr_type; 50 typedef Cdr cdr_type;
69 51
52 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
70 cons() 53 cons()
71 : car(), cdr() {} 54 : car(), cdr() {}
72 55
56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
73 explicit cons(typename detail::call_param<Car>::type in_car) 57 explicit cons(typename detail::call_param<Car>::type in_car)
74 : car(in_car), cdr() {} 58 : car(in_car), cdr() {}
75 59
60 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
76 cons( 61 cons(
77 typename detail::call_param<Car>::type in_car 62 typename detail::call_param<Car>::type in_car
78 , typename detail::call_param<Cdr>::type in_cdr) 63 , typename detail::call_param<Cdr>::type in_cdr)
79 : car(in_car), cdr(in_cdr) {} 64 : car(in_car), cdr(in_cdr) {}
80 65
81 template <typename Car2, typename Cdr2> 66 template <typename Car2, typename Cdr2>
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
82 cons(cons<Car2, Cdr2> const& rhs) 68 cons(cons<Car2, Cdr2> const& rhs)
83 : car(rhs.car), cdr(rhs.cdr) {} 69 : car(rhs.car), cdr(rhs.cdr) {}
84 70
71 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
85 cons(cons const& rhs) 72 cons(cons const& rhs)
86 : car(rhs.car), cdr(rhs.cdr) {} 73 : car(rhs.car), cdr(rhs.cdr) {}
87 74
88 template <typename Sequence> 75 template <typename Sequence>
76 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
89 cons( 77 cons(
90 Sequence const& seq 78 Sequence const& seq
91 , typename boost::disable_if< 79 , typename boost::enable_if<
92 mpl::or_< 80 mpl::and_<
93 is_convertible<Sequence, cons> // use copy ctor instead 81 traits::is_sequence<Sequence>
94 , is_convertible<Sequence, Car> // use copy to car instead 82 , mpl::not_<is_convertible<Sequence, Car> > > // use copy to car instead
95 >
96 >::type* /*dummy*/ = 0 83 >::type* /*dummy*/ = 0
97 ) 84 )
98 : car(*fusion::begin(seq)) 85 : car(*fusion::begin(seq))
99 , cdr(fusion::next(fusion::begin(seq)), mpl::true_()) {} 86 , cdr(fusion::next(fusion::begin(seq)), mpl::true_()) {}
100 87
101 template <typename Iterator> 88 template <typename Iterator>
89 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
102 cons(Iterator const& iter, mpl::true_ /*this_is_an_iterator*/) 90 cons(Iterator const& iter, mpl::true_ /*this_is_an_iterator*/)
103 : car(*iter) 91 : car(*iter)
104 , cdr(fusion::next(iter), mpl::true_()) {} 92 , cdr(fusion::next(iter), mpl::true_()) {}
105 93
106 template <typename Car2, typename Cdr2> 94 template <typename Car2, typename Cdr2>
95 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
107 cons& operator=(cons<Car2, Cdr2> const& rhs) 96 cons& operator=(cons<Car2, Cdr2> const& rhs)
108 { 97 {
109 car = rhs.car; 98 car = rhs.car;
110 cdr = rhs.cdr; 99 cdr = rhs.cdr;
111 return *this; 100 return *this;
112 } 101 }
113 102
103 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
114 cons& operator=(cons const& rhs) 104 cons& operator=(cons const& rhs)
115 { 105 {
116 car = rhs.car; 106 car = rhs.car;
117 cdr = rhs.cdr; 107 cdr = rhs.cdr;
118 return *this; 108 return *this;
119 } 109 }
120 110
121 template <typename Sequence> 111 template <typename Sequence>
122 typename boost::disable_if<is_convertible<Sequence, Car>, cons&>::type 112 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
113 typename boost::enable_if<
114 mpl::and_<
115 traits::is_sequence<Sequence>
116 , mpl::not_<is_convertible<Sequence, Car> > >
117 , cons&>::type
123 operator=(Sequence const& seq) 118 operator=(Sequence const& seq)
124 { 119 {
125 typedef typename result_of::begin<Sequence const>::type Iterator; 120 typedef typename result_of::begin<Sequence const>::type Iterator;
126 Iterator iter = fusion::begin(seq); 121 Iterator iter = fusion::begin(seq);
127 this->assign_from_iter(iter); 122 this->assign_from_iter(iter);
128 return *this; 123 return *this;
129 } 124 }
130 125
131 template <typename Iterator> 126 template <typename Iterator>
127 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
132 void assign_from_iter(Iterator const& iter) 128 void assign_from_iter(Iterator const& iter)
133 { 129 {
134 car = *iter; 130 car = *iter;
135 cdr.assign_from_iter(fusion::next(iter)); 131 cdr.assign_from_iter(fusion::next(iter));
136 } 132 }