mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 12:07:36 +02:00
migrated std_pair_iterator and mpl_iterator to iterator_facade
[SVN r35321]
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
@ -22,14 +22,14 @@ namespace boost { namespace fusion
|
||||
{
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
template<typename Array, std::size_t Pos>
|
||||
template <typename Array, int Pos>
|
||||
struct array_iterator
|
||||
: iterator_facade<array_iterator<Array, Pos>, 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<Pos> index;
|
||||
typedef mpl::int_<Pos> index;
|
||||
typedef Array array_type;
|
||||
|
||||
array_iterator(Array& a)
|
||||
@ -63,36 +63,6 @@ namespace boost { namespace fusion
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next
|
||||
{
|
||||
typedef typename Iterator::array_type array_type;
|
||||
typedef typename Iterator::index index;
|
||||
static int const index_val = index::value;
|
||||
typedef array_iterator<array_type, index_val + 1> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior
|
||||
{
|
||||
typedef typename Iterator::array_type array_type;
|
||||
typedef typename Iterator::index index;
|
||||
static int const index_val = index::value;
|
||||
typedef array_iterator<array_type, index_val - 1> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename N>
|
||||
struct advance
|
||||
{
|
||||
@ -107,15 +77,23 @@ namespace boost { namespace fusion
|
||||
}
|
||||
};
|
||||
|
||||
template <typename First, typename Last>
|
||||
struct distance : mpl::minus<typename Last::index, typename First::index>
|
||||
template <typename Iterator>
|
||||
struct next : advance<Iterator, mpl::int_<1> > {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior : advance<Iterator, mpl::int_<-1> > {};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct distance : mpl::minus<typename I2::index, typename I1::index>
|
||||
{
|
||||
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<Array, Pos> operator=(const array_iterator<Array, Pos>&);
|
||||
array_iterator<Array, Pos>& operator=(array_iterator<Array, Pos> const&);
|
||||
};
|
||||
}}
|
||||
|
||||
|
@ -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 <boost/mpl/advance.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
struct mpl_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct advance_impl;
|
||||
|
||||
template <>
|
||||
struct advance_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename Iterator, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::advance<typename Iterator::iterator_type, N>::type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -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 <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::deref<
|
||||
typename Iterator::iterator_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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 <boost/mpl/minus.hpp>
|
||||
#include <boost/mpl/distance.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct distance_impl;
|
||||
|
||||
template <>
|
||||
struct distance_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename First, typename Last>
|
||||
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
|
@ -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 <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct equal_to_impl;
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct apply
|
||||
: is_same<
|
||||
typename remove_const<typename I1::iterator_type>::type
|
||||
, typename remove_const<typename I2::iterator_type>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -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 <boost/mpl/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
struct mpl_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::next<typename Iterator::iterator_type>::type
|
||||
> type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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 <boost/mpl/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
struct mpl_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct prior_impl;
|
||||
|
||||
template <>
|
||||
struct prior_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::prior<typename Iterator::iterator_type>::type
|
||||
> type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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 <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_of_impl;
|
||||
|
||||
template <>
|
||||
struct value_of_impl<mpl_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::deref<
|
||||
typename Iterator::iterator_type>::type
|
||||
type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,30 +8,104 @@
|
||||
#if !defined(FUSION_MPL_ITERATOR_05052005_0731)
|
||||
#define FUSION_MPL_ITERATOR_05052005_0731
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/support/detail/mpl_iterator_category.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/deref_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/next_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/prior_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/value_of_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/equal_to_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/distance_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/mpl/detail/advance_impl.hpp>
|
||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/prior.hpp>
|
||||
#include <boost/mpl/advance.hpp>
|
||||
#include <boost/mpl/distance.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct mpl_iterator_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
struct mpl_iterator
|
||||
: iterator_base<mpl_iterator<Iterator> >
|
||||
: iterator_facade<
|
||||
mpl_iterator<Iterator>
|
||||
, typename detail::mpl_iterator_category<typename Iterator::category>::type
|
||||
>
|
||||
{
|
||||
typedef mpl_iterator_tag fusion_tag;
|
||||
typedef typename detail::mpl_iterator_category<
|
||||
typename Iterator::category>::type
|
||||
category;
|
||||
typedef typename remove_const<Iterator>::type iterator_type;
|
||||
|
||||
template <typename Iterator>
|
||||
struct value_of : mpl::deref<typename Iterator::iterator_type> {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct deref
|
||||
{
|
||||
typedef typename mpl::deref<
|
||||
typename Iterator::iterator_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::next<typename Iterator::iterator_type>::type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::prior<typename Iterator::iterator_type>::type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename N>
|
||||
struct advance
|
||||
{
|
||||
typedef mpl_iterator<
|
||||
typename mpl::advance<typename Iterator::iterator_type, N>::type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
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();
|
||||
}
|
||||
};
|
||||
};
|
||||
}}
|
||||
|
||||
|
@ -8,39 +8,130 @@
|
||||
#if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934)
|
||||
#define FUSION_STD_PAIR_ITERATOR_09262005_0934
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
//~ #include <boost/fusion/support/iterator_base.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp>
|
||||
//~ #include <boost/type_traits/add_const.hpp>
|
||||
|
||||
|
||||
|
||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
template <typename Pair, int N>
|
||||
struct std_pair_iterator_identity;
|
||||
|
||||
template <typename Pair, int N>
|
||||
struct std_pair_iterator
|
||||
: iterator_base<std_pair_iterator<Pair, N> >
|
||||
: iterator_facade<std_pair_iterator<Pair, N>, random_access_traversal_tag>
|
||||
{
|
||||
BOOST_MPL_ASSERT_RELATION(N, >=, 0);
|
||||
BOOST_MPL_ASSERT_RELATION(N, <=, 2);
|
||||
|
||||
typedef mpl::int_<N> index;
|
||||
typedef std_pair_iterator_tag fusion_tag;
|
||||
typedef random_access_traversal_tag category;
|
||||
typedef std_pair_iterator_identity<
|
||||
typename add_const<Pair>::type, N> identity;
|
||||
typedef Pair pair_type;
|
||||
|
||||
std_pair_iterator(Pair& pair)
|
||||
: pair(pair) {}
|
||||
Pair& pair;
|
||||
|
||||
template <typename Iterator>
|
||||
struct value_of;
|
||||
|
||||
template <typename Pair_>
|
||||
struct value_of<std_pair_iterator<Pair_, 0> >
|
||||
: mpl::identity<typename Pair_::first_type> {};
|
||||
|
||||
template <typename Pair_>
|
||||
struct value_of<std_pair_iterator<Pair_, 1> >
|
||||
: mpl::identity<typename Pair_::second_type> {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct deref;
|
||||
|
||||
template <typename Pair_>
|
||||
struct deref<std_pair_iterator<Pair_, 0> >
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_const<Pair_>
|
||||
, typename Pair_::first_type const&
|
||||
, typename Pair_::first_type&
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(std_pair_iterator<Pair_, 0> const& iter)
|
||||
{
|
||||
return iter.pair.first;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Pair_>
|
||||
struct deref<std_pair_iterator<Pair_, 1> >
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_const<Pair_>
|
||||
, typename Pair_::second_type const&
|
||||
, typename Pair_::second_type&
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(std_pair_iterator<Pair_, 1> const& iter)
|
||||
{
|
||||
return iter.pair.second;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename N>
|
||||
struct advance
|
||||
{
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename Iterator::pair_type pair_type;
|
||||
typedef std_pair_iterator<pair_type, index::value + N::value> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& iter)
|
||||
{
|
||||
return type(iter.pair);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next : advance<Iterator, mpl::int_<1> > {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior : advance<Iterator, mpl::int_<-1> > {};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct distance : mpl::minus<typename I2::index, typename I1::index>
|
||||
{
|
||||
typedef typename
|
||||
mpl::minus<
|
||||
typename I2::index, typename I1::index
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(I1 const&, I2 const&)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
|
@ -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 <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
|
||||
template <typename Vector, int N>
|
||||
struct std_pair_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct advance_impl;
|
||||
|
||||
template <>
|
||||
struct advance_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename Iterator, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename Iterator::pair_type pair_type;
|
||||
typedef std_pair_iterator<pair_type, index::value+N::value> 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
|
@ -12,6 +12,7 @@
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
|
@ -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 <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
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<pair_type>
|
||||
, fusion::detail::cref_result<element>
|
||||
, fusion::detail::ref_result<element>
|
||||
>::type
|
||||
type;
|
||||
|
||||
template <typename RT>
|
||||
static RT get(pair_type& p, mpl::int_<0>)
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
template <typename RT>
|
||||
static RT get(pair_type& p, mpl::int_<1>)
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
|
||||
static type
|
||||
call(Iterator const& iter)
|
||||
{
|
||||
return get<type>(iter.pair, index());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -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 <boost/mpl/minus.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct distance_impl;
|
||||
|
||||
template <>
|
||||
struct distance_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename First, typename Last>
|
||||
struct apply : mpl::minus<typename Last::index, typename First::index>
|
||||
{
|
||||
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
|
@ -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 <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct equal_to_impl;
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct apply
|
||||
: is_same<
|
||||
typename I1::identity
|
||||
, typename I2::identity
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -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 <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
template <typename Vector, int N>
|
||||
struct std_pair_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
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<pair_type, index_val+1> type;
|
||||
BOOST_STATIC_ASSERT((index_val+1) >= 0 &&(index_val+1) <= 2);
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.pair);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -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 <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
template <typename Vector, int N>
|
||||
struct std_pair_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct prior_impl;
|
||||
|
||||
template <>
|
||||
struct prior_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
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<pair_type, index_val-1> type;
|
||||
BOOST_STATIC_ASSERT((index_val-1) >= 0 &&(index_val-1) <= 2);
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.pair);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -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 <boost/static_assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_of_impl;
|
||||
|
||||
template <>
|
||||
struct value_of_impl<std_pair_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
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
|
@ -8,39 +8,130 @@
|
||||
#if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934)
|
||||
#define FUSION_STD_PAIR_ITERATOR_09262005_0934
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp>
|
||||
#include <boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
//~ #include <boost/fusion/support/iterator_base.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/advance_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/deref_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/distance_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/equal_to_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/next_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/prior_impl.hpp>
|
||||
//~ #include <boost/fusion/sequence/adapted/std_pair/detail/value_of_impl.hpp>
|
||||
//~ #include <boost/type_traits/add_const.hpp>
|
||||
|
||||
|
||||
|
||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct std_pair_iterator_tag;
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
template <typename Pair, int N>
|
||||
struct std_pair_iterator_identity;
|
||||
|
||||
template <typename Pair, int N>
|
||||
struct std_pair_iterator
|
||||
: iterator_base<std_pair_iterator<Pair, N> >
|
||||
: iterator_facade<std_pair_iterator<Pair, N>, random_access_traversal_tag>
|
||||
{
|
||||
BOOST_MPL_ASSERT_RELATION(N, >=, 0);
|
||||
BOOST_MPL_ASSERT_RELATION(N, <=, 2);
|
||||
|
||||
typedef mpl::int_<N> index;
|
||||
typedef std_pair_iterator_tag fusion_tag;
|
||||
typedef random_access_traversal_tag category;
|
||||
typedef std_pair_iterator_identity<
|
||||
typename add_const<Pair>::type, N> identity;
|
||||
typedef Pair pair_type;
|
||||
|
||||
std_pair_iterator(Pair& pair)
|
||||
: pair(pair) {}
|
||||
Pair& pair;
|
||||
|
||||
template <typename Iterator>
|
||||
struct value_of;
|
||||
|
||||
template <typename Pair_>
|
||||
struct value_of<std_pair_iterator<Pair_, 0> >
|
||||
: mpl::identity<typename Pair_::first_type> {};
|
||||
|
||||
template <typename Pair_>
|
||||
struct value_of<std_pair_iterator<Pair_, 1> >
|
||||
: mpl::identity<typename Pair_::second_type> {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct deref;
|
||||
|
||||
template <typename Pair_>
|
||||
struct deref<std_pair_iterator<Pair_, 0> >
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_const<Pair_>
|
||||
, typename Pair_::first_type const&
|
||||
, typename Pair_::first_type&
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(std_pair_iterator<Pair_, 0> const& iter)
|
||||
{
|
||||
return iter.pair.first;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Pair_>
|
||||
struct deref<std_pair_iterator<Pair_, 1> >
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_const<Pair_>
|
||||
, typename Pair_::second_type const&
|
||||
, typename Pair_::second_type&
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(std_pair_iterator<Pair_, 1> const& iter)
|
||||
{
|
||||
return iter.pair.second;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename N>
|
||||
struct advance
|
||||
{
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename Iterator::pair_type pair_type;
|
||||
typedef std_pair_iterator<pair_type, index::value + N::value> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& iter)
|
||||
{
|
||||
return type(iter.pair);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next : advance<Iterator, mpl::int_<1> > {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior : advance<Iterator, mpl::int_<-1> > {};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct distance : mpl::minus<typename I2::index, typename I1::index>
|
||||
{
|
||||
typedef typename
|
||||
mpl::minus<
|
||||
typename I2::index, typename I1::index
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(I1 const&, I2 const&)
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}}
|
||||
|
||||
|
Reference in New Issue
Block a user