c++ port of deque underway

[SVN r77808]
This commit is contained in:
Joel de Guzman
2012-04-07 09:56:07 +00:00
parent e15c27bc8b
commit 93ce3bd9bf
10 changed files with 49 additions and 41 deletions

View File

@ -9,7 +9,7 @@
#define BOOST_FUSION_SEQUENCE_CONTAINER_DEQUE_24112006_2036 #define BOOST_FUSION_SEQUENCE_CONTAINER_DEQUE_24112006_2036
#include <boost/fusion/container/deque/deque.hpp> #include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/deque/convert.hpp> //#include <boost/fusion/container/deque/convert.hpp>
#endif #endif

View File

@ -14,11 +14,12 @@
#include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/container/deque/detail/keyed_element.hpp> #include <boost/fusion/container/deque/detail/keyed_element.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion
{
template<typename Deque, typename T> template<typename Deque, typename T>
struct back_extended_deque struct back_extended_deque
: detail::keyed_element<typename Deque::next_up, T, Deque>, : detail::keyed_element<typename Deque::next_up, T, Deque>
sequence_base<back_extended_deque<Deque, T> > , sequence_base<back_extended_deque<Deque, T> >
{ {
typedef detail::keyed_element<typename Deque::next_up, T, Deque> base; typedef detail::keyed_element<typename Deque::next_up, T, Deque> base;
typedef typename Deque::next_down next_down; typedef typename Deque::next_down next_down;

View File

@ -13,7 +13,7 @@
|| defined(BOOST_NO_RVALUE_REFERENCES)) || defined(BOOST_NO_RVALUE_REFERENCES))
# include <boost/fusion/container/deque/cpp03_deque.hpp> # include <boost/fusion/container/deque/cpp03_deque.hpp>
#else #else
# include <boost/fusion/container/deque/cpp03_deque.hpp> # include <boost/fusion/container/deque/cpp11_deque.hpp>
#endif #endif
#endif #endif

View File

@ -15,7 +15,7 @@
|| defined(BOOST_NO_RVALUE_REFERENCES)) || defined(BOOST_NO_RVALUE_REFERENCES))
# include <boost/fusion/container/deque/cpp03_deque_fwd.hpp> # include <boost/fusion/container/deque/cpp03_deque_fwd.hpp>
#else #else
# include <boost/fusion/container/deque/cpp03_deque_fwd.hpp> # include <boost/fusion/container/deque/cpp11_deque_fwd.hpp>
#endif #endif
#endif #endif

View File

@ -2,7 +2,7 @@
Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#if !defined(BOOST_FUSION_DEQUE_ITERATOR_26112006_2154) #if !defined(BOOST_FUSION_DEQUE_ITERATOR_26112006_2154)
@ -12,13 +12,13 @@
#include <boost/fusion/container/deque/detail/keyed_element.hpp> #include <boost/fusion/container/deque/detail/keyed_element.hpp>
#include <boost/mpl/minus.hpp> #include <boost/mpl/minus.hpp>
#include <boost/mpl/equal_to.hpp> #include <boost/mpl/equal_to.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct bidirectional_traversal_tag; struct bidirectional_traversal_tag;
template<typename Seq, int Pos> template <typename Seq, int Pos>
struct deque_iterator struct deque_iterator
: iterator_facade<deque_iterator<Seq, Pos>, bidirectional_traversal_tag> : iterator_facade<deque_iterator<Seq, Pos>, bidirectional_traversal_tag>
{ {
@ -84,7 +84,7 @@ namespace boost { namespace fusion {
typedef typename typedef typename
mpl::minus< mpl::minus<
typename I2::index, typename I1::index typename I2::index, typename I1::index
>::type >::type
type; type;
static type static type

View File

@ -2,7 +2,7 @@
Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#if !defined(BOOST_FUSION_DEQUE_AT_IMPL_09122006_2017) #if !defined(BOOST_FUSION_DEQUE_AT_IMPL_09122006_2017)
@ -19,15 +19,15 @@
#include <boost/type_traits/add_const.hpp> #include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct deque_tag; struct deque_tag;
namespace extension namespace extension
{ {
template<typename T> template<typename T>
struct at_impl; struct at_impl;
template<> template<>
struct at_impl<deque_tag> struct at_impl<deque_tag>
{ {
@ -37,10 +37,13 @@ namespace boost { namespace fusion {
typedef typename Sequence::next_up next_up; typedef typename Sequence::next_up next_up;
typedef typename Sequence::next_down next_down; typedef typename Sequence::next_down next_down;
BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value); BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
typedef mpl::plus<next_down, mpl::int_<1> > offset; static int const offset = next_down::value + 1;
typedef mpl::int_<mpl::plus<N, offset>::value> adjusted_index; typedef mpl::int_<(N::value + offset)> adjusted_index;
typedef typename detail::keyed_element_value_at<Sequence, adjusted_index>::type element_type; typedef typename
detail::keyed_element_value_at<Sequence, adjusted_index>::type
element_type;
typedef typename add_reference< typedef typename add_reference<
typename mpl::eval_if< typename mpl::eval_if<
is_const<Sequence>, is_const<Sequence>,

View File

@ -2,7 +2,7 @@
Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#if !defined(BOOST_FUSION_DEQUE_BEGIN_IMPL_09122006_2034) #if !defined(BOOST_FUSION_DEQUE_BEGIN_IMPL_09122006_2034)
@ -13,27 +13,29 @@
#include <boost/mpl/equal_to.hpp> #include <boost/mpl/equal_to.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct deque_tag; struct deque_tag;
namespace extension namespace extension
{ {
template<typename T> template<typename T>
struct begin_impl; struct begin_impl;
template<> template<>
struct begin_impl<deque_tag> struct begin_impl<deque_tag>
{ {
template<typename Sequence> template<typename Sequence>
struct apply struct apply
{ {
typedef typename mpl::if_< typedef typename
mpl::equal_to<typename Sequence::next_down, typename Sequence::next_up>, mpl::if_c<
deque_iterator<Sequence, 0>, (Sequence::next_down::value == Sequence::next_up::value)
deque_iterator< , deque_iterator<Sequence, 0>
Sequence, mpl::plus<typename Sequence::next_down, mpl::int_<1> >::value> >::type type; , deque_iterator<Sequence, (Sequence::next_down::value + 1)>
>::type
type;
static type call(Sequence& seq) static type call(Sequence& seq)
{ {
return type(seq); return type(seq);

View File

@ -2,7 +2,7 @@
Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#if !defined(BOOST_FUSION_DEQUE_DETAIL_KEYED_ELEMENT_26112006_1330) #if !defined(BOOST_FUSION_DEQUE_DETAIL_KEYED_ELEMENT_26112006_1330)
@ -26,7 +26,7 @@ namespace detail {
void get(); void get();
template<typename It> template<typename It>
static nil_keyed_element static nil_keyed_element
from_iterator(It const&) from_iterator(It const&)
{ {
return nil_keyed_element(); return nil_keyed_element();
@ -49,7 +49,7 @@ namespace detail {
*it, base::from_iterator(fusion::next(it))); *it, base::from_iterator(fusion::next(it)));
} }
template<typename U, typename Rst> template <typename U, typename Rst>
keyed_element(keyed_element<Key, U, Rst> const& rhs) keyed_element(keyed_element<Key, U, Rst> const& rhs)
: Rest(rhs.get_base()), value_(rhs.value_) : Rest(rhs.get_base()), value_(rhs.value_)
{} {}

View File

@ -2,7 +2,7 @@
Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#if !defined(BOOST_FUSION_DEQUE_VALUE_AT_IMPL_08122006_0756) #if !defined(BOOST_FUSION_DEQUE_VALUE_AT_IMPL_08122006_0756)
@ -13,15 +13,15 @@
#include <boost/mpl/equal_to.hpp> #include <boost/mpl/equal_to.hpp>
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct deque_tag; struct deque_tag;
namespace extension namespace extension
{ {
template<typename T> template<typename T>
struct value_at_impl; struct value_at_impl;
template<> template<>
struct value_at_impl<deque_tag> struct value_at_impl<deque_tag>
{ {
@ -31,10 +31,12 @@ namespace boost { namespace fusion {
typedef typename Sequence::next_up next_up; typedef typename Sequence::next_up next_up;
typedef typename Sequence::next_down next_down; typedef typename Sequence::next_down next_down;
BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value); BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
typedef mpl::plus<next_down, mpl::int_<1> > offset; static int const offset = next_down::value + 1;
typedef mpl::int_<mpl::plus<N, offset>::value> adjusted_index; typedef mpl::int_<(N::value + offset)> adjusted_index;
typedef typename detail::keyed_element_value_at<Sequence, adjusted_index>::type type; typedef typename
detail::keyed_element_value_at<Sequence, adjusted_index>::type
type;
}; };
}; };
} }

View File

@ -17,8 +17,8 @@ namespace boost { namespace fusion
{ {
template<typename Deque, typename T> template<typename Deque, typename T>
struct front_extended_deque struct front_extended_deque
: detail::keyed_element<typename Deque::next_down, T, Deque>, : detail::keyed_element<typename Deque::next_down, T, Deque>
sequence_base<front_extended_deque<Deque, T> > , sequence_base<front_extended_deque<Deque, T> >
{ {
typedef detail::keyed_element<typename Deque::next_down, T, Deque> base; typedef detail::keyed_element<typename Deque::next_down, T, Deque> base;
typedef mpl::int_<(Deque::next_down::value - 1)> next_down; typedef mpl::int_<(Deque::next_down::value - 1)> next_down;