diff options
Diffstat (limited to 'boost/fusion/container/deque/deque.hpp')
-rw-r--r-- | boost/fusion/container/deque/deque.hpp | 101 |
1 files changed, 87 insertions, 14 deletions
diff --git a/boost/fusion/container/deque/deque.hpp b/boost/fusion/container/deque/deque.hpp index 215981e422..6fd3e1b0ce 100644 --- a/boost/fusion/container/deque/deque.hpp +++ b/boost/fusion/container/deque/deque.hpp @@ -8,27 +8,23 @@ #if !defined(BOOST_FUSION_DEQUE_26112006_1649) #define BOOST_FUSION_DEQUE_26112006_1649 -#include <boost/config.hpp> +# include <boost/fusion/container/deque/deque_fwd.hpp> /////////////////////////////////////////////////////////////////////////////// -// With no decltype and variadics, we will use the C++03 version +// Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// -#if (defined(BOOST_NO_DECLTYPE) \ - || defined(BOOST_NO_VARIADIC_TEMPLATES) \ - || defined(BOOST_NO_RVALUE_REFERENCES)) -# include <boost/fusion/container/deque/detail/cpp03_deque.hpp> +#if !defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) +# include <boost/fusion/container/deque/detail/cpp03/deque.hpp> #else -# if !defined(BOOST_FUSION_HAS_CPP11_DEQUE) -# define BOOST_FUSION_HAS_CPP11_DEQUE -# endif /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// #include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/support/detail/access.hpp> +#include <boost/fusion/support/is_sequence.hpp> #include <boost/fusion/container/deque/detail/keyed_element.hpp> -#include <boost/fusion/container/deque/detail/cpp11_deque_keyed_values.hpp> +#include <boost/fusion/container/deque/detail/deque_keyed_values.hpp> #include <boost/fusion/container/deque/deque_fwd.hpp> #include <boost/fusion/container/deque/detail/value_at_impl.hpp> #include <boost/fusion/container/deque/detail/at_impl.hpp> @@ -36,8 +32,10 @@ #include <boost/fusion/container/deque/detail/end_impl.hpp> #include <boost/fusion/container/deque/detail/is_sequence_impl.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> +#include <boost/fusion/sequence/intrinsic/empty.hpp> #include <boost/mpl/int.hpp> +#include <boost/mpl/and.hpp> #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_convertible.hpp> @@ -48,6 +46,24 @@ namespace boost { namespace fusion template <typename ...Elements> struct deque : detail::nil_keyed_element { + typedef deque_tag fusion_tag; + typedef bidirectional_traversal_tag category; + typedef mpl::int_<0> size; + typedef mpl::int_<0> next_up; + typedef mpl::int_<0> next_down; + typedef mpl::false_ is_view; + + template <typename Sequence> + BOOST_FUSION_GPU_ENABLED + deque(Sequence const&, + typename enable_if< + mpl::and_< + traits::is_sequence<Sequence> + , result_of::empty<Sequence>>>::type* /*dummy*/ = 0) + {} + + BOOST_FUSION_GPU_ENABLED + deque() {} }; template <typename Head, typename ...Tail> @@ -60,29 +76,74 @@ namespace boost { namespace fusion typedef typename detail::deque_keyed_values<Head, Tail...>::type base; typedef mpl::int_<(sizeof ...(Tail) + 1)> size; typedef mpl::int_<size::value> next_up; - typedef mpl::int_<mpl::int_<((size::value == 0) ? 0 : -1)>::type::value> next_down; + typedef mpl::int_<((size::value == 0) ? 0 : -1)> next_down; typedef mpl::false_ is_view; + BOOST_FUSION_GPU_ENABLED deque() {} template <typename ...Elements> + BOOST_FUSION_GPU_ENABLED deque(deque<Elements...> const& seq) : base(seq) {} - explicit deque(typename detail::call_param<Head>::type head - , typename detail::call_param<Tail>::type... tail) - : base(detail::deque_keyed_values<Head, Tail...>::call(head, tail...)) + template <typename ...Elements> + BOOST_FUSION_GPU_ENABLED + deque(deque<Elements...>& seq) + : base(seq) {} +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template <typename ...Elements> + BOOST_FUSION_GPU_ENABLED + deque(deque<Elements...>&& seq) + : base(std::forward<deque<Elements...>>(seq)) + {} +#endif + + BOOST_FUSION_GPU_ENABLED + deque(deque const& seq) + : base(seq) + {} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + BOOST_FUSION_GPU_ENABLED + deque(deque&& seq) + : base(std::forward<deque>(seq)) + {} +#endif + + BOOST_FUSION_GPU_ENABLED + explicit deque(Head const& head, Tail const&... tail) + : base(detail::deque_keyed_values<Head, Tail...>::construct(head, tail...)) + {} + + template <typename Head_, typename ...Tail_> + BOOST_FUSION_GPU_ENABLED + explicit deque(Head_ const& head, Tail_ const&... tail) + : base(detail::deque_keyed_values<Head_, Tail_...>::construct(head, tail...)) + {} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template <typename Head_, typename ...Tail_> + BOOST_FUSION_GPU_ENABLED + explicit deque(Head_&& head, Tail_&&... tail) + : base(detail::deque_keyed_values<Head, Tail...> + ::forward_(std::forward<Head_>(head), std::forward<Tail_>(tail)...)) + {} +#endif + template <typename Sequence> + BOOST_FUSION_GPU_ENABLED explicit deque(Sequence const& seq , typename disable_if<is_convertible<Sequence, Head> >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename ...Elements> + BOOST_FUSION_GPU_ENABLED deque& operator=(deque<Elements...> const& rhs) { base::operator=(rhs); @@ -90,11 +151,23 @@ namespace boost { namespace fusion } template <typename T> + BOOST_FUSION_GPU_ENABLED deque& operator=(T const& rhs) { base::operator=(rhs); return *this; } + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template <typename T> + BOOST_FUSION_GPU_ENABLED + deque& operator=(T&& rhs) + { + base::operator=(std::forward<T>(rhs)); + return *this; + } +#endif + }; }} |