From ac31f6d1cb8e3c1b5c12036c63393ce36a94918b Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 25 Sep 2006 13:56:22 +0000 Subject: [PATCH] migrated std_pair_iterator and mpl_iterator to iterator_facade [SVN r35321] --- .../sequence/adapted/array/array_iterator.hpp | 60 +++------ .../adapted/mpl/detail/advance_impl.hpp | 45 ------- .../adapted/mpl/detail/deref_impl.hpp | 44 ------ .../adapted/mpl/detail/distance_impl.hpp | 48 ------- .../adapted/mpl/detail/equal_to_impl.hpp | 41 ------ .../sequence/adapted/mpl/detail/next_impl.hpp | 47 ------- .../adapted/mpl/detail/prior_impl.hpp | 47 ------- .../adapted/mpl/detail/value_of_impl.hpp | 38 ------ .../sequence/adapted/mpl/mpl_iterator.hpp | 104 +++++++++++--- .../std_pair/Attic/std_pair_iterator.hpp | 127 +++++++++++++++--- .../adapted/std_pair/detail/Attic/at_impl.hpp | 1 + .../adapted/std_pair/detail/advance_impl.hpp | 47 ------- .../adapted/std_pair/detail/at_impl.hpp | 1 + .../adapted/std_pair/detail/deref_impl.hpp | 74 ---------- .../adapted/std_pair/detail/distance_impl.hpp | 42 ------ .../adapted/std_pair/detail/equal_to_impl.hpp | 40 ------ .../adapted/std_pair/detail/next_impl.hpp | 46 ------- .../adapted/std_pair/detail/prior_impl.hpp | 46 ------- .../adapted/std_pair/detail/value_of_impl.hpp | 46 ------- .../adapted/std_pair/std_pair_iterator.hpp | 127 +++++++++++++++--- 20 files changed, 328 insertions(+), 743 deletions(-) delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/advance_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/deref_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/distance_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/equal_to_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/next_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/prior_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/mpl/detail/value_of_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp delete mode 100644 include/boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp diff --git a/include/boost/fusion/sequence/adapted/array/array_iterator.hpp b/include/boost/fusion/sequence/adapted/array/array_iterator.hpp index 71a9921c..a0eef60f 100644 --- a/include/boost/fusion/sequence/adapted/array/array_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/array/array_iterator.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -22,14 +22,14 @@ namespace boost { namespace fusion { struct random_access_traversal_tag; - template + template struct array_iterator : iterator_facade, random_access_traversal_tag> { - BOOST_MPL_ASSERT_RELATION(Pos,>=,0); - BOOST_MPL_ASSERT_RELATION(Pos,<=,std::size_t(Array::static_size)); + BOOST_MPL_ASSERT_RELATION(Pos, >=, 0); + BOOST_MPL_ASSERT_RELATION(Pos, <=, Array::static_size); - typedef mpl::size_t index; + typedef mpl::int_ index; typedef Array array_type; array_iterator(Array& a) @@ -63,36 +63,6 @@ namespace boost { namespace fusion } }; - template - struct next - { - typedef typename Iterator::array_type array_type; - typedef typename Iterator::index index; - static int const index_val = index::value; - typedef array_iterator type; - - static type - call(Iterator const& i) - { - return type(i.array); - } - }; - - template - struct prior - { - typedef typename Iterator::array_type array_type; - typedef typename Iterator::index index; - static int const index_val = index::value; - typedef array_iterator type; - - static type - call(Iterator const& i) - { - return type(i.array); - } - }; - template struct advance { @@ -107,15 +77,23 @@ namespace boost { namespace fusion } }; - template - struct distance : mpl::minus + template + struct next : advance > {}; + + template + struct prior : advance > {}; + + template + struct distance : mpl::minus { - typedef typename mpl::minus< - typename Last::index, typename First::index>::type + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type type; static type - call(First const&, Last const&) + call(I1 const&, I2 const&) { return type(); } @@ -123,7 +101,7 @@ namespace boost { namespace fusion private: - array_iterator operator=(const array_iterator&); + array_iterator& operator=(array_iterator const&); }; }} diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/advance_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/advance_impl.hpp deleted file mode 100644 index 9603a737..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/advance_impl.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_ADVANCE_IMPL_09232005_2324) -#define FUSION_ADVANCE_IMPL_09232005_2324 - -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - template - struct mpl_iterator; - - namespace extension - { - template - struct advance_impl; - - template <> - struct advance_impl - { - template - struct apply - { - typedef mpl_iterator< - typename mpl::advance::type> - type; - - static type - call(Iterator const& i) - { - return type(); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/deref_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/deref_impl.hpp deleted file mode 100644 index e692c93b..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/deref_impl.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_DEREF_IMPL_05052005_0733) -#define FUSION_DEREF_IMPL_05052005_0733 - -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - namespace extension - { - template - struct deref_impl; - - template <> - struct deref_impl - { - template - struct apply - { - typedef typename mpl::deref< - typename Iterator::iterator_type>::type - type; - - static type - call(Iterator) - { - return type(); - } - }; - }; - } -}} - -#endif - - diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/distance_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/distance_impl.hpp deleted file mode 100644 index 893c3112..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/distance_impl.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_DISTANCE_IMPL_09232005_2303) -#define FUSION_DISTANCE_IMPL_09232005_2303 - -#include -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - namespace extension - { - template - struct distance_impl; - - template <> - struct distance_impl - { - template - struct apply - : mpl::distance< - typename First::iterator_type - , typename Last::iterator_type> - { - static typename mpl::distance< - typename First::iterator_type - , typename Last::iterator_type>::type - call(First const&, Last const&) - { - typedef typename mpl::distance< - typename First::iterator_type - , typename Last::iterator_type>::type - result; - return result(); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/equal_to_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/equal_to_impl.hpp deleted file mode 100644 index 25a3e886..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/equal_to_impl.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_EQUAL_TO_IMPL_05232005_0621) -#define FUSION_EQUAL_TO_IMPL_05232005_0621 - -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - namespace extension - { - template - struct equal_to_impl; - - template <> - struct equal_to_impl - { - template - struct apply - : is_same< - typename remove_const::type - , typename remove_const::type - > - { - }; - }; - } -}} - -#endif - diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/next_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/next_impl.hpp deleted file mode 100644 index 6427e283..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/next_impl.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_NEXT_IMPL_05052005_0733) -#define FUSION_NEXT_IMPL_05052005_0733 - -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - template - struct mpl_iterator; - - namespace extension - { - template - struct next_impl; - - template <> - struct next_impl - { - template - struct apply - { - typedef mpl_iterator< - typename mpl::next::type - > type; - - static type - call(Iterator) - { - return type(); - } - }; - }; - } -}} - -#endif - - diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/prior_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/prior_impl.hpp deleted file mode 100644 index e2ae56be..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/prior_impl.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_PRIOR_IMPL_05202005_0930) -#define FUSION_PRIOR_IMPL_05202005_0930 - -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - template - struct mpl_iterator; - - namespace extension - { - template - struct prior_impl; - - template <> - struct prior_impl - { - template - struct apply - { - typedef mpl_iterator< - typename mpl::prior::type - > type; - - static type - call(Iterator) - { - return type(); - } - }; - }; - } -}} - -#endif - - diff --git a/include/boost/fusion/sequence/adapted/mpl/detail/value_of_impl.hpp b/include/boost/fusion/sequence/adapted/mpl/detail/value_of_impl.hpp deleted file mode 100644 index 3d7c9fff..00000000 --- a/include/boost/fusion/sequence/adapted/mpl/detail/value_of_impl.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_VALUE_OF_TRAITS_05052005_0734) -#define FUSION_VALUE_OF_TRAITS_05052005_0734 - -#include - -namespace boost { namespace fusion -{ - struct mpl_iterator_tag; - - namespace extension - { - template - struct value_of_impl; - - template <> - struct value_of_impl - { - template - struct apply - { - typedef typename mpl::deref< - typename Iterator::iterator_type>::type - type; - }; - }; - } -}} - -#endif - - diff --git a/include/boost/fusion/sequence/adapted/mpl/mpl_iterator.hpp b/include/boost/fusion/sequence/adapted/mpl/mpl_iterator.hpp index 68612a44..baf85db4 100644 --- a/include/boost/fusion/sequence/adapted/mpl/mpl_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/mpl/mpl_iterator.hpp @@ -8,30 +8,104 @@ #if !defined(FUSION_MPL_ITERATOR_05052005_0731) #define FUSION_MPL_ITERATOR_05052005_0731 -#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include namespace boost { namespace fusion { - struct mpl_iterator_tag; - template struct mpl_iterator - : iterator_base > + : iterator_facade< + mpl_iterator + , typename detail::mpl_iterator_category::type + > { - typedef mpl_iterator_tag fusion_tag; - typedef typename detail::mpl_iterator_category< - typename Iterator::category>::type - category; typedef typename remove_const::type iterator_type; + + template + struct value_of : mpl::deref {}; + + template + struct deref + { + typedef typename mpl::deref< + typename Iterator::iterator_type>::type + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template + struct next + { + typedef mpl_iterator< + typename mpl::next::type> + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template + struct prior + { + typedef mpl_iterator< + typename mpl::prior::type> + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template + struct advance + { + typedef mpl_iterator< + typename mpl::advance::type> + type; + + static type + call(Iterator const& i) + { + return type(); + } + }; + + template + struct distance : + mpl::distance< + typename I1::iterator_type + , typename I2::iterator_type> + { + typedef typename + mpl::distance< + typename I1::iterator_type + , typename I2::iterator_type + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; }; }} diff --git a/include/boost/fusion/sequence/adapted/std_pair/Attic/std_pair_iterator.hpp b/include/boost/fusion/sequence/adapted/std_pair/Attic/std_pair_iterator.hpp index 1121e315..a2cb7f52 100644 --- a/include/boost/fusion/sequence/adapted/std_pair/Attic/std_pair_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/std_pair/Attic/std_pair_iterator.hpp @@ -8,39 +8,130 @@ #if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934) #define FUSION_STD_PAIR_ITERATOR_09262005_0934 -#include -#include -#include -#include -#include -#include -#include -#include -#include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include + + + +#include +#include +#include +#include +#include #include +#include +#include namespace boost { namespace fusion { - struct std_pair_iterator_tag; struct random_access_traversal_tag; - template - struct std_pair_iterator_identity; - template struct std_pair_iterator - : iterator_base > + : iterator_facade, random_access_traversal_tag> { + BOOST_MPL_ASSERT_RELATION(N, >=, 0); + BOOST_MPL_ASSERT_RELATION(N, <=, 2); + typedef mpl::int_ index; - typedef std_pair_iterator_tag fusion_tag; - typedef random_access_traversal_tag category; - typedef std_pair_iterator_identity< - typename add_const::type, N> identity; typedef Pair pair_type; std_pair_iterator(Pair& pair) : pair(pair) {} Pair& pair; + + template + struct value_of; + + template + struct value_of > + : mpl::identity {}; + + template + struct value_of > + : mpl::identity {}; + + template + struct deref; + + template + struct deref > + { + typedef typename + mpl::if_< + is_const + , typename Pair_::first_type const& + , typename Pair_::first_type& + >::type + type; + + static type + call(std_pair_iterator const& iter) + { + return iter.pair.first; + } + }; + + template + struct deref > + { + typedef typename + mpl::if_< + is_const + , typename Pair_::second_type const& + , typename Pair_::second_type& + >::type + type; + + static type + call(std_pair_iterator const& iter) + { + return iter.pair.second; + } + }; + + template + struct advance + { + typedef typename Iterator::index index; + typedef typename Iterator::pair_type pair_type; + typedef std_pair_iterator type; + + static type + call(Iterator const& iter) + { + return type(iter.pair); + } + }; + + template + struct next : advance > {}; + + template + struct prior : advance > {}; + + template + struct distance : mpl::minus + { + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; }; }} diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/Attic/at_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/Attic/at_impl.hpp index dce5f86c..b257089d 100644 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/Attic/at_impl.hpp +++ b/include/boost/fusion/sequence/adapted/std_pair/detail/Attic/at_impl.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp deleted file mode 100644 index 6a883994..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_ADVANCE_IMPL_09302005_1847) -#define FUSION_ADVANCE_IMPL_09302005_1847 - -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - - template - struct std_pair_iterator; - - namespace extension - { - template - struct advance_impl; - - template <> - struct advance_impl - { - template - struct apply - { - typedef typename Iterator::index index; - typedef typename Iterator::pair_type pair_type; - typedef std_pair_iterator type; - BOOST_STATIC_ASSERT( - (index::value+N::value) >= 0 &&(index::value+N::value) < 2); - - static type - call(Iterator const& i) - { - return type(i.vec); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/at_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/at_impl.hpp index dce5f86c..b257089d 100644 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/at_impl.hpp +++ b/include/boost/fusion/sequence/adapted/std_pair/detail/at_impl.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp deleted file mode 100644 index 371cf2ce..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_DEREF_IMPL_09302005_1846) -#define FUSION_DEREF_IMPL_09302005_1846 - -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - - namespace extension - { - template - struct deref_impl; - - template <> - struct deref_impl - { - template - struct apply - { - typedef typename Iterator::pair_type pair_type; - typedef typename Iterator::index index; - static int const index_val = index::value; - - BOOST_STATIC_ASSERT(index_val >= 0 && index_val <= 2); - typedef typename - mpl::if_c< - (index::value == 0) - , typename pair_type::first_type - , typename pair_type::second_type - > - element; - - typedef typename - mpl::eval_if< - is_const - , fusion::detail::cref_result - , fusion::detail::ref_result - >::type - type; - - template - static RT get(pair_type& p, mpl::int_<0>) - { - return p.first; - } - - template - static RT get(pair_type& p, mpl::int_<1>) - { - return p.second; - } - - static type - call(Iterator const& iter) - { - return get(iter.pair, index()); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp deleted file mode 100644 index ad1761b7..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_DISTANCE_IMPL_09302005_1846) -#define FUSION_DISTANCE_IMPL_09302005_1846 - -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - - namespace extension - { - template - struct distance_impl; - - template <> - struct distance_impl - { - template - struct apply : mpl::minus - { - static typename mpl::minus< - typename Last::index, typename First::index>::type - call(First const&, Last const&) - { - typedef typename mpl::minus< - typename Last::index, typename First::index>::type - result; - return result(); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp deleted file mode 100644 index 85088280..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_EQUAL_TO_IMPL_09302005_1847) -#define FUSION_EQUAL_TO_IMPL_09302005_1847 - -#include -#include -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - - namespace extension - { - template - struct equal_to_impl; - - template <> - struct equal_to_impl - { - template - struct apply - : is_same< - typename I1::identity - , typename I2::identity - > - { - }; - }; - } -}} - -#endif - diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp deleted file mode 100644 index dc320903..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_NEXT_IMPL_09302005_1847) -#define FUSION_NEXT_IMPL_09302005_1847 - -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - template - struct std_pair_iterator; - - namespace extension - { - template - struct next_impl; - - template <> - struct next_impl - { - template - struct apply - { - typedef typename Iterator::pair_type pair_type; - typedef typename Iterator::index index; - static int const index_val = index::value; - typedef std_pair_iterator type; - BOOST_STATIC_ASSERT((index_val+1) >= 0 &&(index_val+1) <= 2); - - static type - call(Iterator const& i) - { - return type(i.pair); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp deleted file mode 100644 index fe243185..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_PRIOR_IMPL_09302005_1847) -#define FUSION_PRIOR_IMPL_09302005_1847 - -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - template - struct std_pair_iterator; - - namespace extension - { - template - struct prior_impl; - - template <> - struct prior_impl - { - template - struct apply - { - typedef typename Iterator::pair_type pair_type; - typedef typename Iterator::index index; - static int const index_val = index::value; - typedef std_pair_iterator type; - BOOST_STATIC_ASSERT((index_val-1) >= 0 &&(index_val-1) <= 2); - - static type - call(Iterator const& i) - { - return type(i.pair); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp b/include/boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp deleted file mode 100644 index 240b56e9..00000000 --- a/include/boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to 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_VALUE_OF_IMPL_09302005_1847) -#define FUSION_VALUE_OF_IMPL_09302005_1847 - -#include -#include - -namespace boost { namespace fusion -{ - struct std_pair_iterator_tag; - - namespace extension - { - template - struct value_of_impl; - - template <> - struct value_of_impl - { - template - struct apply - { - typedef typename Iterator::pair_type pair_type; - typedef typename Iterator::index index; - static int const index_value = index::value; - - BOOST_STATIC_ASSERT(index_value >= 0 && index_value <= 2); - typedef typename - mpl::if_c< - (index_value == 0) - , typename pair_type::first_type - , typename pair_type::second_type - >::type - type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp b/include/boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp index 1121e315..a2cb7f52 100644 --- a/include/boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp @@ -8,39 +8,130 @@ #if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934) #define FUSION_STD_PAIR_ITERATOR_09262005_0934 -#include -#include -#include -#include -#include -#include -#include -#include -#include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include +//~ #include + + + +#include +#include +#include +#include +#include #include +#include +#include namespace boost { namespace fusion { - struct std_pair_iterator_tag; struct random_access_traversal_tag; - template - struct std_pair_iterator_identity; - template struct std_pair_iterator - : iterator_base > + : iterator_facade, random_access_traversal_tag> { + BOOST_MPL_ASSERT_RELATION(N, >=, 0); + BOOST_MPL_ASSERT_RELATION(N, <=, 2); + typedef mpl::int_ index; - typedef std_pair_iterator_tag fusion_tag; - typedef random_access_traversal_tag category; - typedef std_pair_iterator_identity< - typename add_const::type, N> identity; typedef Pair pair_type; std_pair_iterator(Pair& pair) : pair(pair) {} Pair& pair; + + template + struct value_of; + + template + struct value_of > + : mpl::identity {}; + + template + struct value_of > + : mpl::identity {}; + + template + struct deref; + + template + struct deref > + { + typedef typename + mpl::if_< + is_const + , typename Pair_::first_type const& + , typename Pair_::first_type& + >::type + type; + + static type + call(std_pair_iterator const& iter) + { + return iter.pair.first; + } + }; + + template + struct deref > + { + typedef typename + mpl::if_< + is_const + , typename Pair_::second_type const& + , typename Pair_::second_type& + >::type + type; + + static type + call(std_pair_iterator const& iter) + { + return iter.pair.second; + } + }; + + template + struct advance + { + typedef typename Iterator::index index; + typedef typename Iterator::pair_type pair_type; + typedef std_pair_iterator type; + + static type + call(Iterator const& iter) + { + return type(iter.pair); + } + }; + + template + struct next : advance > {}; + + template + struct prior : advance > {}; + + template + struct distance : mpl::minus + { + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; }; }}