Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
/*=============================================================================
Copyright (c) 2001-2011 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 boost_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<boost_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,141 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
#define BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion
{
namespace extension
{
template <typename>
struct value_of_impl;
template <typename>
struct deref_impl;
template <typename>
struct value_of_data_impl;
template <typename>
struct key_of_impl;
template <typename>
struct deref_data_impl;
}
template<typename Tag, typename Category, typename Seq, int Index>
struct basic_iterator
: iterator_facade<basic_iterator<Tag,Category,Seq,Index>, Category>
{
typedef mpl::int_<Index> index;
typedef Seq seq_type;
template <typename It>
struct value_of
: extension::value_of_impl<Tag>::template apply<It>
{};
template <typename It>
struct deref
: extension::deref_impl<Tag>::template apply<It>
{};
template <typename It>
struct value_of_data
: extension::value_of_data_impl<Tag>::template apply<It>
{};
template <typename It>
struct key_of
: extension::key_of_impl<Tag>::template apply<It>
{};
template <typename It>
struct deref_data
: extension::deref_data_impl<Tag>::template apply<It>
{};
template <typename It, typename N>
struct advance
{
typedef
basic_iterator<Tag, Category, Seq, Index + N::value>
type;
static type
call(It const& it)
{
return type(*it.seq,0);
}
};
template <typename It>
struct next
: advance<It, mpl::int_<1> >
{};
template <typename It>
struct prior
: advance<It, mpl::int_<-1> >
{};
template <typename It1, typename It2>
struct distance
{
typedef mpl::minus<typename It2::index, typename It1::index> type;
static
type
call(It1 const&, It2 const&)
{
return type();
}
};
template <typename It1, typename It2>
struct equal_to
: mpl::and_<
is_same<
typename remove_const<typename It1::seq_type>::type
, typename remove_const<typename It2::seq_type>::type
>
, mpl::equal_to<typename It1::index,typename It2::index>
>
{};
template<typename OtherSeq>
basic_iterator(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
: seq(it.seq)
{}
basic_iterator(Seq& in_seq, int)
: seq(&in_seq)
{}
template<typename OtherSeq>
basic_iterator&
operator=(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
{
seq=it.seq;
return *this;
}
Seq* seq;
};
}}
#endif

View File

@@ -0,0 +1,72 @@
/*=============================================================================
Copyright (c) 2001-2011 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 boost_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<boost_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,49 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_DEREF_DATA_HPP
#define BOOST_FUSION_ITERATOR_DEREF_DATA_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template deref_data<It>
{};
};
}
namespace result_of
{
template <typename It>
struct deref_data
: extension::deref_data_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
template <typename It>
typename result_of::deref_data<It>::type
deref_data(It const& it)
{
return result_of::deref_data<It>::call(it);
}
}}
#endif

View File

@@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2001-2011 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-2011 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-2011 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-2011 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,71 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
namespace boost { namespace fusion { namespace detail
{
struct segment_sequence_tag {};
// Here, Sequence is a sequence of ranges (which may or may not be
// segmented).
template<typename Sequence>
struct segment_sequence
: sequence_base<segment_sequence<Sequence> >
{
typedef fusion_sequence_tag tag;
typedef segment_sequence_tag fusion_tag;
typedef typename Sequence::is_view is_view;
typedef typename Sequence::category category;
typedef Sequence sequence_type;
sequence_type sequence;
explicit segment_sequence(Sequence const & seq)
: sequence(seq)
{}
};
}
namespace extension
{
template<typename Tag>
struct is_segmented_impl;
template<>
struct is_segmented_impl<detail::segment_sequence_tag>
{
template<typename Sequence>
struct apply
: mpl::true_
{};
};
template<typename Tag>
struct segments_impl;
template<>
struct segments_impl<detail::segment_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef typename Sequence::sequence_type type;
static type call(Sequence & seq)
{
return seq.sequence;
}
};
};
}}}
#endif

View File

@@ -0,0 +1,41 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_ITERATOR_EQUAL_TO_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_ITERATOR_EQUAL_TO_HPP_INCLUDED
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
namespace boost { namespace fusion
{
struct nil;
namespace detail
{
template <typename Stack1, typename Stack2>
struct segmented_equal_to
: mpl::and_<
segmented_equal_to<
typename Stack1::cdr_type,
typename Stack2::cdr_type
>
, result_of::equal_to<
typename Stack1::car_type::begin_type,
typename Stack2::car_type::begin_type
>
>
{};
template <>
struct segmented_equal_to<fusion::nil, fusion::nil>
: mpl::true_
{};
}
}}
#endif

View File

@@ -0,0 +1,144 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_ITERATOR_SEGMENTED_ITERATOR_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_ITERATOR_SEGMENTED_ITERATOR_HPP_INCLUDED
#include <boost/mpl/bool.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/detail/segmented_equal_to.hpp>
namespace boost { namespace fusion
{
struct nil;
namespace detail
{
template <typename Stack>
struct segmented_next_impl;
}
// A segmented iterator wraps a "context", which is a cons list
// of ranges, the frontmost is range over values and the rest
// are ranges over internal segments.
template <typename Context>
struct segmented_iterator
: iterator_facade<segmented_iterator<Context>, forward_traversal_tag>
{
explicit segmented_iterator(Context const& ctx)
: context(ctx)
{}
//auto deref(it)
//{
// return deref(begin(car(it.context)))
//}
template <typename It>
struct deref
{
typedef
typename result_of::deref<
typename It::context_type::car_type::begin_type
>::type
type;
static type call(It const& it)
{
return *it.context.car.first;
}
};
//auto deref_data(it)
//{
// return deref_data(begin(car(it.context)))
//}
template <typename It>
struct deref_data
{
typedef
typename result_of::deref_data<
typename It::context_type::car_type::begin_type
>::type
type;
static type call(It const& it)
{
return fusion::deref_data(it.context.car.first);
}
};
//auto key_of(it)
//{
// return key_of(begin(car(it.context)))
//}
template <typename It>
struct key_of
: result_of::key_of<typename It::context_type::car_type::begin_type>
{};
//auto value_of(it)
//{
// return value_of(begin(car(it.context)))
//}
template <typename It>
struct value_of
: result_of::value_of<typename It::context_type::car_type::begin_type>
{};
//auto value_of_data(it)
//{
// return value_of_data(begin(car(it.context)))
//}
template <typename It>
struct value_of_data
: result_of::value_of_data<typename It::context_type::car_type::begin_type>
{};
// Compare all the segment iterators in each stack, starting with
// the bottom-most.
template <
typename It1
, typename It2
, int Size1 = It1::context_type::size::value
, int Size2 = It2::context_type::size::value
>
struct equal_to
: mpl::false_
{};
template <typename It1, typename It2, int Size>
struct equal_to<It1, It2, Size, Size>
: detail::segmented_equal_to<
typename It1::context_type
, typename It2::context_type
>
{};
template <typename It>
struct next
{
typedef detail::segmented_next_impl<typename It::context_type> impl;
typedef segmented_iterator<typename impl::type> type;
static type call(It const& it)
{
return type(impl::call(it.context));
}
};
typedef Context context_type;
context_type context;
};
}}
#endif

View File

@@ -0,0 +1,254 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/list/cons_fwd.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/deref.hpp>
namespace boost { namespace fusion
{
template <typename First, typename Second>
struct iterator_range;
template <typename Context>
struct segmented_iterator;
namespace detail
{
template <typename Sequence, typename Stack>
struct segmented_begin_impl;
//bool is_invalid(stack)
//{
// return empty(car(stack));
//}
template <typename Stack>
struct is_invalid
: result_of::equal_to<
typename Stack::car_type::begin_type,
typename Stack::car_type::end_type
>
{};
////Advance the first iterator in the seq at the
////top of a stack of iterator ranges. Return the
////new stack.
//auto pop_front_car(stack)
//{
// return cons(iterator_range(next(begin(car(stack))), end(car(stack))), cdr(stack));
//}
template <typename Stack>
struct pop_front_car
{
typedef
iterator_range<
typename result_of::next<
typename Stack::car_type::begin_type
>::type
, typename Stack::car_type::end_type
>
car_type;
typedef
cons<car_type, typename Stack::cdr_type>
type;
static type call(Stack const & stack)
{
return type(
car_type(fusion::next(stack.car.first), stack.car.last),
stack.cdr);
}
};
template <
typename Stack,
typename Next = typename pop_front_car<Stack>::type,
bool IsInvalid = is_invalid<Next>::value,
int StackSize = Stack::size::value>
struct segmented_next_impl_recurse;
// Handle the case where the top of the stack has no usable
//auto segmented_next_impl_recurse3(stack)
//{
// if (size(stack) == 1)
// return cons(iterator_range(end(car(stack)), end(car(stack))), nil);
// else
// return segmented_next_impl_recurse(stack.cdr);
//}
template <
typename Stack,
int StackSize = Stack::size::value>
struct segmented_next_impl_recurse3
{
typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
typedef typename impl::type type;
static type call(Stack const & stack)
{
return impl::call(stack.cdr);
}
};
template <typename Stack>
struct segmented_next_impl_recurse3<Stack, 1>
{
typedef typename Stack::car_type::end_type end_type;
typedef iterator_range<end_type, end_type> range_type;
typedef cons<range_type> type;
static type call(Stack const & stack)
{
return type(range_type(stack.car.last, stack.car.last));
}
};
//auto segmented_next_impl_recurse2(stack)
//{
// auto res = segmented_begin_impl(front(car(stack)), stack);
// if (is_invalid(res))
// return segmented_next_impl_recurse3(stack);
// else
// return res;
//}
template <
typename Stack,
typename Sequence =
typename remove_reference<
typename add_const<
typename result_of::deref<
typename Stack::car_type::begin_type
>::type
>::type
>::type,
typename Result =
typename segmented_begin_impl<Sequence, Stack>::type,
bool IsInvalid =
is_invalid<Result>::value>
struct segmented_next_impl_recurse2
{
typedef segmented_next_impl_recurse3<Stack> impl;
typedef typename impl::type type;
static type call(Stack const & stack)
{
return impl::call(stack);
}
};
template <typename Stack, typename Sequence, typename Result>
struct segmented_next_impl_recurse2<Stack, Sequence, Result, false>
{
typedef Result type;
static type call(Stack const & stack)
{
return segmented_begin_impl<Sequence, Stack>::call(*stack.car.first, stack);
}
};
//auto segmented_next_impl_recurse(stack)
//{
// auto next = pop_front_car(stack);
// if (is_invalid(next))
// if (1 == size(stack))
// return next;
// else
// return segmented_next_impl_recurse(cdr(stack));
// else
// return segmented_next_impl_recurse2(next)
//}
template <typename Stack, typename Next, bool IsInvalid, int StackSize>
struct segmented_next_impl_recurse
{
typedef
typename segmented_next_impl_recurse<typename Stack::cdr_type>::type
type;
static type call(Stack const& stack)
{
return segmented_next_impl_recurse<typename Stack::cdr_type>::call(stack.cdr);
}
};
template <typename Stack, typename Next>
struct segmented_next_impl_recurse<Stack, Next, true, 1>
{
typedef Next type;
static type call(Stack const & stack)
{
return pop_front_car<Stack>::call(stack);
}
};
template <typename Stack, typename Next, int StackSize>
struct segmented_next_impl_recurse<Stack, Next, false, StackSize>
{
typedef segmented_next_impl_recurse2<Next> impl;
typedef typename impl::type type;
static type call(Stack const & stack)
{
return impl::call(pop_front_car<Stack>::call(stack));
}
};
//auto segmented_next_impl(stack)
//{
// // car(stack) is a seq of values, not a seq of segments
// auto next = pop_front_car(stack);
// if (is_invalid(next))
// return segmented_next_impl_recurse(cdr(next));
// else
// return next;
//}
template <
typename Stack,
typename Next = typename pop_front_car<Stack>::type,
bool IsInvalid = is_invalid<Next>::value>
struct segmented_next_impl_aux
{
typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
typedef typename impl::type type;
static type call(Stack const & stack)
{
return impl::call(stack.cdr);
}
};
template <typename Stack, typename Next>
struct segmented_next_impl_aux<Stack, Next, false>
{
typedef Next type;
static type call(Stack const & stack)
{
return pop_front_car<Stack>::call(stack);
}
};
template <typename Stack>
struct segmented_next_impl
: segmented_next_impl_aux<Stack>
{};
}
}}
#endif

View File

@@ -0,0 +1,78 @@
/*=============================================================================
Copyright (c) 2001-2011 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 boost_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>
{};
};
template <>
struct distance_impl<iterator_facade_tag>
{
template <typename First, typename Last>
struct apply : First::template distance<First, Last> {};
};
template <>
struct distance_impl<boost_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,103 @@
/*=============================================================================
Copyright (c) 2001-2011 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 boost_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 It1, typename It2, typename Tag1, typename Tag2>
struct dispatch : mpl::false_ {};
template <typename It1, typename It2, typename Tag>
struct dispatch<It1, It2, Tag, Tag> // same tag
: It1::template equal_to<It1, It2>
{};
template<typename It1, typename It2>
struct apply : dispatch<It1, It2,
typename It1::fusion_tag, typename It2::fusion_tag>
{};
};
template <>
struct equal_to_impl<boost_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,125 @@
/*=============================================================================
Copyright (c) 2001-2011 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_ADAPTER_08112011_0942)
#define FUSION_ITERATOR_ADAPTER_08112011_0942
#include <boost/fusion/iterator/detail/advance.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion
{
template <typename Derived_, typename Iterator_,
typename Category = typename Iterator_::category>
struct iterator_adapter
: iterator_facade<Derived_, Category>
{
typedef typename
remove_const<Iterator_>::type
iterator_base_type;
iterator_base_type iterator_base;
iterator_adapter(iterator_base_type const& iterator_base)
: iterator_base(iterator_base) {}
// default implementation
template <typename I1, typename I2>
struct equal_to
: result_of::equal_to<
typename I1::iterator_base_type
, typename I2::iterator_base_type
>
{};
// default implementation
template <typename Iterator, typename N>
struct advance
{
typedef typename Derived_::template make<
typename result_of::advance<
typename Iterator::iterator_base_type, N
>::type>::type
type;
static type
call(Iterator const& it)
{
return type(fusion::advance<N>(it.iterator_base));
}
};
// default implementation
template <typename First, typename Last>
struct distance
: result_of::distance<
typename First::iterator_base_type
, typename Last::iterator_base_type
>
{};
// default implementation
template <typename Iterator>
struct value_of
: result_of::value_of<
typename Iterator::iterator_base_type
>
{};
// default implementation
template <typename Iterator>
struct deref
{
typedef typename
result_of::deref<
typename Iterator::iterator_base_type
>::type
type;
static type
call(Iterator const& it)
{
return fusion::deref(it.iterator_base);
}
};
// default implementation
template <typename Iterator>
struct next
{
typedef typename Derived_::template make<
typename result_of::next<
typename Iterator::iterator_base_type
>::type>::type
type;
static type
call(Iterator const& i)
{
return type(fusion::next(i.iterator_base));
}
};
// default implementation
template <typename Iterator>
struct prior
{
typedef typename Derived_::template make<
typename result_of::prior<
typename Iterator::iterator_base_type
>::type>::type
type;
static type
call(Iterator const& i)
{
return type(fusion::prior(i.iterator_base));
}
};
};
}}
#endif

View File

@@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2011 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/iterator/detail/distance.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>));
};
// default implementation
template <typename First, typename Last>
struct distance :
distance_detail::linear_distance<First, Last>
{};
};
}}
#endif

View File

@@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_KEY_OF_HPP
#define BOOST_FUSION_ITERATOR_KEY_OF_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template key_of<It>
{};
};
}
namespace result_of
{
template <typename It>
struct key_of
: extension::key_of_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
}}
#endif

View File

@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2001-2011 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-2011 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,79 @@
/*=============================================================================
Copyright (c) 2001-2011 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>
#include <boost/mpl/iterator_tags.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
namespace boost { namespace fusion { namespace detail
{
template<class Category>
struct to_mpl_category {
typedef typename mpl::eval_if<
is_base_of<random_access_traversal_tag, Category>,
mpl::random_access_iterator_tag,
mpl::eval_if<
is_base_of<bidirectional_traversal_tag, Category>,
mpl::bidirectional_iterator_tag,
mpl::forward_iterator_tag
>
>::type type;
};
}}}
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 fusion_category;
typedef typename fusion::detail::to_mpl_category<fusion_category>::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-2011 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 boost_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<boost_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-2011 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 boost_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<boost_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,15 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_ITERATOR_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_ITERATOR_HPP_INCLUDED
#include <boost/fusion/iterator/detail/segmented_iterator.hpp>
#include <boost/fusion/iterator/detail/segmented_next_impl.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/container/list/cons.hpp>
#endif

View File

@@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2011 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 boost_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<boost_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

View File

@@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP
#define BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template value_of_data<It>
{};
};
}
namespace result_of
{
template <typename It>
struct value_of_data
: extension::value_of_data_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
}}
#endif