|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77809 - trunk/boost/fusion/container/deque
From: joel_at_[hidden]
Date: 2012-04-07 06:08:00
Author: djowel
Date: 2012-04-07 06:08:00 EDT (Sat, 07 Apr 2012)
New Revision: 77809
URL: http://svn.boost.org/trac/boost/changeset/77809
Log:
c++ port of deque working
Added:
trunk/boost/fusion/container/deque/cpp11_deque.hpp (contents, props changed)
trunk/boost/fusion/container/deque/cpp11_deque_fwd.hpp (contents, props changed)
Added: trunk/boost/fusion/container/deque/cpp11_deque.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/fusion/container/deque/cpp11_deque.hpp 2012-04-07 06:08:00 EDT (Sat, 07 Apr 2012)
@@ -0,0 +1,127 @@
+/*=============================================================================
+ Copyright (c) 2005-2012 Joel de Guzman
+ Copyright (c) 2005-2006 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#if !defined(BOOST_CPP03_FUSION_DEQUE_26112006_1649)
+#define BOOST_CPP03_FUSION_DEQUE_26112006_1649
+
+#include <boost/type_traits/add_reference.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+
+#include <boost/fusion/support/sequence_base.hpp>
+#include <boost/fusion/container/deque/detail/keyed_element.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>
+#include <boost/fusion/container/deque/detail/begin_impl.hpp>
+#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/mpl/int.hpp>
+#include <boost/utility/enable_if.hpp>
+
+namespace boost { namespace fusion
+{
+ namespace detail
+ {
+ template<typename Key, typename Value, typename Rest>
+ struct keyed_element;
+
+ template <typename N, typename ...Elements>
+ struct deque_keyed_values_impl;
+
+ template <typename N, typename Head, typename ...Tail>
+ struct deque_keyed_values_impl<N, Head, Tail...>
+ {
+ typedef mpl::int_<(N::value + 1)> next_index;
+ typedef typename deque_keyed_values_impl<next_index, Tail...>::type tail;
+ typedef keyed_element<N, Head, tail> type;
+
+ static type call(
+ typename add_reference<typename add_const<Head>::type>::type head
+ , typename add_reference<typename add_const<Tail>::type>::type... tail)
+ {
+ return type(
+ head
+ , deque_keyed_values_impl<next_index, Tail...>::call(tail...)
+ );
+ }
+ };
+
+ struct nil_keyed_element;
+
+ template <typename N>
+ struct deque_keyed_values_impl<N>
+ {
+ typedef nil_keyed_element type;
+ static type call() { return type(); }
+ };
+
+ template <typename ...Elements>
+ struct deque_keyed_values
+ : deque_keyed_values_impl<mpl::int_<0>, Elements...> {};
+ }
+
+ struct deque_tag;
+
+ template <typename ...Elements>
+ struct deque;
+
+ template <typename Head, typename ...Tail>
+ struct deque<Head, Tail...>
+ : detail::deque_keyed_values<Head, Tail...>::type
+ , sequence_base<deque<Head, Tail...>>
+ {
+ typedef deque_tag fusion_tag;
+ typedef bidirectional_traversal_tag category;
+ 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::false_ is_view;
+
+ deque()
+ {}
+
+ explicit deque(typename add_reference<typename add_const<Head>::type>::type elem)
+ : base(elem, detail::nil_keyed_element())
+ {}
+
+ template <typename ...Elements>
+ deque(deque<Elements...> const& seq)
+ : base(seq)
+ {}
+
+ deque(typename add_reference<typename add_const<Head>::type>::type head
+ , typename add_reference<typename add_const<Tail>::type>::type... tail)
+ : base(detail::deque_keyed_values<Head, Tail...>::call(head, tail...))
+ {}
+
+ template <typename Sequence>
+ deque(Sequence const& seq
+ , typename disable_if<is_convertible<Sequence, Head> >::type* /*dummy*/ = 0)
+ : base(base::from_iterator(fusion::begin(seq)))
+ {}
+
+ template <typename ...Elements>
+ deque& operator=(deque<Elements...> const& rhs)
+ {
+ base::operator=(rhs);
+ return *this;
+ }
+
+ template <typename T>
+ deque& operator=(T const& rhs)
+ {
+ base::operator=(rhs);
+ return *this;
+ }
+ };
+}}
+
+#endif
Added: trunk/boost/fusion/container/deque/cpp11_deque_fwd.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/fusion/container/deque/cpp11_deque_fwd.hpp 2012-04-07 06:08:00 EDT (Sat, 07 Apr 2012)
@@ -0,0 +1,19 @@
+/*=============================================================================
+ Copyright (c) 2005-2012 Joel de Guzman
+ Copyright (c) 2005-2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#if !defined(FUSION_CPP11_DEQUE_FORWARD_04072012_0355)
+#define FUSION_CPP11_DEQUE_FORWARD_04072012_0355
+
+namespace boost { namespace fusion
+{
+ struct void_;
+
+ template <typename ...T>
+ struct deque;
+}}
+
+#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk