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