migrated std_pair_iterator and mpl_iterator to iterator_facade

[SVN r35321]
This commit is contained in:
Joel de Guzman
2006-09-25 13:56:22 +00:00
parent f017aa86ce
commit ac31f6d1cb
20 changed files with 328 additions and 743 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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