1 /*=============================================================================
2 Copyright (c) 2005-2012 Joel de Guzman
3 Copyright (c) 2005-2006 Dan Marsden
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_FUSION_DEQUE_26112006_1649)
9 #define BOOST_FUSION_DEQUE_26112006_1649
11 # include <boost/fusion/container/deque/deque_fwd.hpp>
13 ///////////////////////////////////////////////////////////////////////////////
14 // Without variadics, we will use the PP version
15 ///////////////////////////////////////////////////////////////////////////////
16 #if !defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
17 # include <boost/fusion/container/deque/detail/cpp03/deque.hpp>
20 ///////////////////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////////////////
23 #include <boost/fusion/support/sequence_base.hpp>
24 #include <boost/fusion/support/void.hpp>
25 #include <boost/fusion/support/detail/enabler.hpp>
26 #include <boost/fusion/support/detail/access.hpp>
27 #include <boost/fusion/support/is_sequence.hpp>
28 #include <boost/fusion/container/deque/detail/keyed_element.hpp>
29 #include <boost/fusion/container/deque/detail/deque_keyed_values.hpp>
30 #include <boost/fusion/container/deque/deque_fwd.hpp>
31 #include <boost/fusion/container/deque/detail/value_at_impl.hpp>
32 #include <boost/fusion/container/deque/detail/at_impl.hpp>
33 #include <boost/fusion/container/deque/detail/begin_impl.hpp>
34 #include <boost/fusion/container/deque/detail/end_impl.hpp>
35 #include <boost/fusion/container/deque/detail/is_sequence_impl.hpp>
36 #include <boost/fusion/sequence/intrinsic/begin.hpp>
37 #include <boost/fusion/sequence/intrinsic/empty.hpp>
39 #include <boost/mpl/int.hpp>
40 #include <boost/mpl/and.hpp>
41 #include <boost/utility/enable_if.hpp>
42 #include <boost/type_traits/is_convertible.hpp>
44 namespace boost { namespace fusion
48 template <typename ...Elements>
49 struct deque : detail::nil_keyed_element
51 typedef deque_tag fusion_tag;
52 typedef bidirectional_traversal_tag category;
53 typedef mpl::int_<0> size;
54 typedef mpl::int_<0> next_up;
55 typedef mpl::int_<-1> next_down;
56 typedef mpl::false_ is_view;
58 template <typename Sequence>
59 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
60 deque(Sequence const&,
63 traits::is_sequence<Sequence>
64 , result_of::empty<Sequence>>, detail::enabler_>::type = detail::enabler) BOOST_NOEXCEPT
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
68 deque() BOOST_NOEXCEPT {}
71 template <typename Head, typename ...Tail>
72 struct deque<Head, Tail...>
73 : detail::deque_keyed_values<Head, Tail...>::type
74 , sequence_base<deque<Head, Tail...>>
76 typedef deque_tag fusion_tag;
77 typedef bidirectional_traversal_tag category;
78 typedef typename detail::deque_keyed_values<Head, Tail...>::type base;
79 typedef mpl::int_<(sizeof ...(Tail) + 1)> size;
80 typedef mpl::int_<size::value> next_up;
81 typedef mpl::int_<-1> next_down;
82 typedef mpl::false_ is_view;
84 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
88 template <typename Head_, typename ...Tail_, typename =
89 typename enable_if<is_convertible<Head_, Head> >::type
91 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
92 deque(deque<Head_, Tail_...> const& seq)
96 template <typename Head_, typename ...Tail_, typename =
97 typename enable_if<is_convertible<Head_, Head> >::type
99 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
100 deque(deque<Head_, Tail_...>& seq)
104 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
105 template <typename Head_, typename ...Tail_, typename =
106 typename enable_if<is_convertible<Head_, Head> >::type
108 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
109 deque(deque<Head_, Tail_...>&& seq)
110 : base(std::forward<deque<Head_, Tail_...>>(seq))
114 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
115 deque(deque const& seq)
119 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
120 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
122 : base(std::forward<deque>(seq))
126 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
127 explicit deque(typename detail::call_param<Head>::type head
128 , typename detail::call_param<Tail>::type... tail)
129 : base(detail::deque_keyed_values<Head, Tail...>::construct(head, tail...))
132 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
133 template <typename Head_, typename ...Tail_, typename =
134 typename enable_if<is_convertible<Head_, Head> >::type
136 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
137 explicit deque(Head_&& head, Tail_&&... tail)
138 : base(detail::deque_keyed_values<Head, Tail...>
139 ::forward_(BOOST_FUSION_FWD_ELEM(Head_, head), BOOST_FUSION_FWD_ELEM(Tail_, tail)...))
142 template <typename Head_, typename ...Tail_, typename =
143 typename enable_if<is_convertible<Head_, Head> >::type
145 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
146 explicit deque(Head_ const& head, Tail_ const&... tail)
147 : base(detail::deque_keyed_values<Head_, Tail_...>::construct(head, tail...))
151 template <typename Sequence>
152 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
153 explicit deque(Sequence const& seq
154 , typename disable_if<is_convertible<Sequence, Head>, detail::enabler_>::type = detail::enabler
155 , typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
156 : base(base::from_iterator(fusion::begin(seq)))
159 template <typename ...Elements>
160 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
161 deque& operator=(deque<Elements...> const& rhs)
163 base::operator=(rhs);
167 template <typename T>
168 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
169 deque& operator=(T const& rhs)
171 base::operator=(rhs);
175 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
176 template <typename T>
177 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
178 deque& operator=(T&& rhs)
180 base::operator=(BOOST_FUSION_FWD_ELEM(T, rhs));