branch for creating branch for fusion 2.1

[SVN r40237]
This commit is contained in:
Joel de Guzman
2007-10-21 00:52:09 +00:00
parent 7a6e82b7cf
commit 32f1c58ce7
476 changed files with 25709 additions and 0 deletions

View File

@ -0,0 +1,92 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ADVANCE_09172005_1146)
#define FUSION_ADVANCE_09172005_1146
#include <boost/fusion/iterator/detail/advance.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct random_access_traversal_tag;
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct advance_impl
{
// default implementation
template <typename Iterator, typename N>
struct apply :
mpl::if_c<
(N::value > 0)
, advance_detail::forward<Iterator, N::value>
, advance_detail::backward<Iterator, N::value>
>::type
{
BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>));
};
};
template <>
struct advance_impl<iterator_facade_tag>
{
template <typename Iterator, typename N>
struct apply : Iterator::template advance<Iterator, N> {};
};
template <>
struct advance_impl<array_iterator_tag>;
template <>
struct advance_impl<mpl_iterator_tag>;
template <>
struct advance_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename Iterator, int N>
struct advance_c
: extension::advance_impl<typename detail::tag_of<Iterator>::type>::template apply<Iterator, mpl::int_<N> >
{};
template <typename Iterator, typename N>
struct advance
: extension::advance_impl<typename detail::tag_of<Iterator>::type>::template apply<Iterator, N>
{};
}
template <int N, typename Iterator>
inline typename result_of::advance_c<Iterator, N>::type const
advance_c(Iterator const& i)
{
return result_of::advance_c<Iterator, N>::call(i);
}
template<typename N, typename Iterator>
inline typename result_of::advance<Iterator, N>::type const
advance(Iterator const& i)
{
return result_of::advance<Iterator, N>::call(i);
}
}} // namespace boost::fusion
#endif

View File

@ -0,0 +1,72 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_DEREF_05042005_1019)
#define FUSION_DEREF_05042005_1019
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct deref_impl
{
template <typename Iterator>
struct apply {};
};
template <>
struct deref_impl<iterator_facade_tag>
{
template <typename Iterator>
struct apply : Iterator::template deref<Iterator> {};
};
template <>
struct deref_impl<array_iterator_tag>;
template <>
struct deref_impl<mpl_iterator_tag>;
template <>
struct deref_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename Iterator>
struct deref
: extension::deref_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
}
template <typename Iterator>
typename result_of::deref<Iterator>::type
deref(Iterator const& i)
{
typedef result_of::deref<Iterator> deref_meta;
return deref_meta::call(i);
}
template <typename Iterator>
typename result_of::deref<Iterator>::type
operator*(iterator_base<Iterator> const& i)
{
return fusion::deref(i.cast());
}
}}
#endif

View File

@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ADAPT_DEREF_TRAITS_05062005_0900)
#define FUSION_ADAPT_DEREF_TRAITS_05062005_0900
#include <boost/fusion/iterator/deref.hpp>
namespace boost { namespace fusion { namespace detail
{
struct adapt_deref_traits
{
template <typename Iterator>
struct apply
{
typedef typename
result_of::deref<typename Iterator::first_type>::type
type;
static type
call(Iterator const& i)
{
return *i.first;
}
};
};
}}}
#endif

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ADAPT_VALUE_TRAITS_05062005_0859)
#define FUSION_ADAPT_VALUE_TRAITS_05062005_0859
#include <boost/fusion/iterator/value_of.hpp>
namespace boost { namespace fusion { namespace detail
{
struct adapt_value_traits
{
template <typename Iterator>
struct apply
{
typedef typename
result_of::value_of<typename Iterator::first_type>::type
type;
};
};
}}}
#endif

View File

@ -0,0 +1,102 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ADVANCE_09172005_1149)
#define FUSION_ADVANCE_09172005_1149
#include <boost/mpl/int.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
namespace boost { namespace fusion { namespace advance_detail
{
// Default advance implementation, perform next(i)
// or prior(i) N times.
template <typename Iterator, int N>
struct forward;
template <typename Iterator, int N>
struct next_forward
{
typedef typename
forward<
typename result_of::next<Iterator>::type
, N-1
>::type
type;
};
template <typename Iterator, int N>
struct forward
{
typedef typename
mpl::eval_if_c<
(N == 0)
, mpl::identity<Iterator>
, next_forward<Iterator, N>
>::type
type;
static type const&
call(type const& i)
{
return i;
}
template <typename I>
static type
call(I const& i)
{
return call(fusion::next(i));
}
};
template <typename Iterator, int N>
struct backward;
template <typename Iterator, int N>
struct next_backward
{
typedef typename
backward<
typename result_of::prior<Iterator>::type
, N+1
>::type
type;
};
template <typename Iterator, int N>
struct backward
{
typedef typename
mpl::eval_if_c<
(N == 0)
, mpl::identity<Iterator>
, next_backward<Iterator, N>
>::type
type;
static type const&
call(type const& i)
{
return i;
}
template <typename I>
static type
call(I const& i)
{
return call(fusion::prior(i));
}
};
}}}
#endif

View File

@ -0,0 +1,64 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_DISTANCE_09172005_0730)
#define FUSION_DISTANCE_09172005_0730
#include <boost/mpl/int.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
namespace boost { namespace fusion { namespace distance_detail
{
// Default distance implementation, linear
// search for the Last iterator.
template <typename First, typename Last>
struct linear_distance;
template <typename First, typename Last>
struct next_distance
{
typedef typename
mpl::next<
typename linear_distance<
typename result_of::next<First>::type
, Last
>::type
>::type
type;
};
template <typename First, typename Last>
struct linear_distance
: mpl::eval_if<
result_of::equal_to<First, Last>
, mpl::identity<mpl::int_<0> >
, next_distance<First, Last>
>::type
{
typedef typename
mpl::eval_if<
result_of::equal_to<First, Last>
, mpl::identity<mpl::int_<0> >
, next_distance<First, Last>
>::type
type;
static type
call(First const&, Last const&)
{
return type();
}
};
}}}
#endif

View File

@ -0,0 +1,81 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_DISTANCE_09172005_0721)
#define FUSION_DISTANCE_09172005_0721
#include <boost/fusion/iterator/detail/distance.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct random_access_traversal_tag;
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct distance_impl
{
// default implementation
template <typename First, typename Last>
struct apply : distance_detail::linear_distance<First, Last>
{
BOOST_MPL_ASSERT_NOT((traits::is_random_access<First>));
BOOST_MPL_ASSERT_NOT((traits::is_random_access<Last>));
};
};
template <>
struct distance_impl<iterator_facade_tag>
{
template <typename First, typename Last>
struct apply : First::template distance<First, Last> {};
};
template <>
struct distance_impl<array_iterator_tag>;
template <>
struct distance_impl<mpl_iterator_tag>;
template <>
struct distance_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename First, typename Last>
struct distance
: extension::distance_impl<typename detail::tag_of<First>::type>::
template apply<First, Last>
{
typedef typename extension::distance_impl<typename detail::tag_of<First>::type>::
template apply<First, Last>::type distance_application;
BOOST_STATIC_CONSTANT(int, value = distance_application::value);
};
}
template <typename First, typename Last>
inline typename result_of::distance<First, Last>::type
distance(First const& a, Last const& b)
{
return result_of::distance<First, Last>::call(a,b);
}
}}
#endif

View File

@ -0,0 +1,93 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_EQUAL_TO_05052005_1208)
#define FUSION_EQUAL_TO_05052005_1208
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/fusion/support/is_iterator.hpp>
#include <boost/mpl/and.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion
{
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct equal_to_impl
{
// default implementation
template <typename I1, typename I2>
struct apply
: is_same<typename add_const<I1>::type, typename add_const<I2>::type>
{};
};
template <>
struct equal_to_impl<iterator_facade_tag>
{
template <typename I1, typename I2>
struct apply : I1::template equal_to<I1, I2> {};
};
template <>
struct equal_to_impl<array_iterator_tag>;
template <>
struct equal_to_impl<mpl_iterator_tag>;
template <>
struct equal_to_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename I1, typename I2>
struct equal_to
: extension::equal_to_impl<typename detail::tag_of<I1>::type>::
template apply<I1, I2>
{};
}
namespace iterator_operators
{
template <typename Iter1, typename Iter2>
inline typename
enable_if<
mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
, bool
>::type
operator==(Iter1 const&, Iter2 const&)
{
return result_of::equal_to<Iter1, Iter2>::value;
}
template <typename Iter1, typename Iter2>
inline typename
enable_if<
mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
, bool
>::type
operator!=(Iter1 const&, Iter2 const&)
{
return !result_of::equal_to<Iter1, Iter2>::value;
}
}
using iterator_operators::operator==;
using iterator_operators::operator!=;
}}
#endif

View File

@ -0,0 +1,50 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ITERATOR_FACADE_09252006_1011)
#define FUSION_ITERATOR_FACADE_09252006_1011
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/iterator/detail/advance.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/assert.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
template <typename Derived, typename Category>
struct iterator_facade : iterator_base<Derived>
{
typedef iterator_facade_tag fusion_tag;
typedef Derived derived_type;
typedef Category category;
// default implementation
template <typename I1, typename I2>
struct equal_to // default implementation
: is_same<
typename I1::derived_type
, typename I2::derived_type
>
{};
// default implementation
template <typename Iterator, typename N>
struct advance :
mpl::if_c<
(N::value > 0)
, advance_detail::forward<Iterator, N::value>
, advance_detail::backward<Iterator, N::value>
>::type
{
BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>));
};
};
}}
#endif

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_ITERATOR_MPL_10022005_0557)
#define FUSION_ITERATOR_MPL_10022005_0557
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
#include <boost/fusion/iterator/mpl/fusion_iterator.hpp>
#endif

View File

@ -0,0 +1,58 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_CONVERT_ITERATOR_05062005_1218)
#define FUSION_CONVERT_ITERATOR_05062005_1218
#include <boost/fusion/support/is_iterator.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
{
template <typename Iterator>
struct mpl_iterator; // forward declaration
// Test T. If it is a fusion iterator, return a reference to it.
// else, assume it is an mpl iterator.
template <typename T>
struct convert_iterator
{
typedef typename
mpl::if_<
is_fusion_iterator<T>
, T
, mpl_iterator<T>
>::type
type;
static T const&
call(T const& x, mpl::true_)
{
return x;
}
static mpl_iterator<T>
call(T const& x, mpl::false_)
{
return mpl_iterator<T>();
}
static typename
mpl::if_<
is_fusion_iterator<T>
, T const&
, mpl_iterator<T>
>::type
call(T const& x)
{
return call(x, is_fusion_iterator<T>());
}
};
}}
#endif

View File

@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_FUSION_ITERATOR_10012005_1551)
#define FUSION_FUSION_ITERATOR_10012005_1551
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/next_prior.hpp>
#include <boost/mpl/advance_fwd.hpp>
#include <boost/mpl/distance_fwd.hpp>
namespace boost { namespace mpl
{
template <typename Iterator>
struct fusion_iterator
{
typedef typename fusion::result_of::value_of<Iterator>::type type;
typedef typename fusion::traits::category_of<Iterator>::type category;
typedef Iterator iterator;
};
template <typename Iterator>
struct next<fusion_iterator<Iterator> >
{
typedef fusion_iterator<typename fusion::result_of::next<Iterator>::type> type;
};
template <typename Iterator>
struct prior<fusion_iterator<Iterator> >
{
typedef fusion_iterator<typename fusion::result_of::prior<Iterator>::type> type;
};
template <typename Iterator, typename N>
struct advance<fusion_iterator<Iterator>, N>
{
typedef fusion_iterator<typename fusion::result_of::advance<Iterator, N>::type> type;
};
template <typename First, typename Last>
struct distance<fusion_iterator<First>, fusion_iterator<Last> >
: fusion::result_of::distance<First, Last>
{};
}}
#endif

View File

@ -0,0 +1,63 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_NEXT_05042005_1101)
#define FUSION_NEXT_05042005_1101
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct next_impl
{
template <typename Iterator>
struct apply {};
};
template <>
struct next_impl<iterator_facade_tag>
{
template <typename Iterator>
struct apply : Iterator::template next<Iterator> {};
};
template <>
struct next_impl<array_iterator_tag>;
template <>
struct next_impl<mpl_iterator_tag>;
template <>
struct next_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename Iterator>
struct next
: extension::next_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
}
template <typename Iterator>
typename result_of::next<Iterator>::type const
next(Iterator const& i)
{
return result_of::next<Iterator>::call(i);
}
}}
#endif

View File

@ -0,0 +1,63 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_PRIOR_05042005_1144)
#define FUSION_PRIOR_05042005_1144
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct prior_impl
{
template <typename Iterator>
struct apply {};
};
template <>
struct prior_impl<iterator_facade_tag>
{
template <typename Iterator>
struct apply : Iterator::template prior<Iterator> {};
};
template <>
struct prior_impl<array_iterator_tag>;
template <>
struct prior_impl<mpl_iterator_tag>;
template <>
struct prior_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename Iterator>
struct prior
: extension::prior_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
}
template <typename Iterator>
typename result_of::prior<Iterator>::type const
prior(Iterator const& i)
{
return result_of::prior<Iterator>::call(i);
}
}}
#endif

View File

@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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_VALUE_OF_05052005_1126)
#define FUSION_VALUE_OF_05052005_1126
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
// Special tags:
struct iterator_facade_tag; // iterator facade tag
struct array_iterator_tag; // boost::array iterator tag
struct mpl_iterator_tag; // mpl sequence iterator tag
struct std_pair_iterator_tag; // std::pair iterator tag
namespace extension
{
template <typename Tag>
struct value_of_impl
{
template <typename Iterator>
struct apply {};
};
template <>
struct value_of_impl<iterator_facade_tag>
{
template <typename Iterator>
struct apply : Iterator::template value_of<Iterator> {};
};
template <>
struct value_of_impl<array_iterator_tag>;
template <>
struct value_of_impl<mpl_iterator_tag>;
template <>
struct value_of_impl<std_pair_iterator_tag>;
}
namespace result_of
{
template <typename Iterator>
struct value_of
: extension::value_of_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
}
}}
#endif