diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/fusion/algorithm/query | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/fusion/algorithm/query')
7 files changed, 645 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/any.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/any.hpp new file mode 100644 index 0000000..8b1fca0 --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/any.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005 Eric Niebler + Copyright (c) 2007 Dan Marsden + + 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_ANY_05052005_1230) +#define FUSION_ANY_05052005_1230 + +#include <boost/fusion/support/category_of.hpp> +#include <boost/fusion/algorithm/query/detail/any.hpp> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename Sequence, typename F> + struct any + { + typedef bool type; + }; + } + + template <typename Sequence, typename F> + inline bool + any(Sequence const& seq, F f) + { + return detail::any(seq, f, typename traits::category_of<Sequence>::type()); + } +}} + +#endif + diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/any.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/any.hpp new file mode 100644 index 0000000..5f6b857 --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/any.hpp @@ -0,0 +1,130 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2005 Eric Niebler + Copyright (c) 2007 Dan Marsden + + 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_ANY_05052005_1229) +#define FUSION_ANY_05052005_1229 + +#include <boost/mpl/bool.hpp> +#include <boost/fusion/sequence/intrinsic/begin.hpp> +#include <boost/fusion/sequence/intrinsic/end.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/iterator/next.hpp> +#include <boost/fusion/iterator/deref.hpp> +#include <boost/fusion/iterator/distance.hpp> + +namespace boost { namespace fusion { + struct random_access_traversal_tag; +namespace detail +{ + template <typename First, typename Last, typename F> + inline bool + linear_any(First const&, Last const&, F const&, mpl::true_) + { + return false; + } + + template <typename First, typename Last, typename F> + inline bool + linear_any(First const& first, Last const& last, F& f, mpl::false_) + { + typename result_of::deref<First>::type x = *first; + return f(x) || + detail::linear_any( + fusion::next(first) + , last + , f + , result_of::equal_to<typename result_of::next<First>::type, Last>()); + } + + template <typename Sequence, typename F, typename Tag> + inline bool + any(Sequence const& seq, F f, Tag) + { + return detail::linear_any( + fusion::begin(seq) + , fusion::end(seq) + , f + , result_of::equal_to< + typename result_of::begin<Sequence>::type + , typename result_of::end<Sequence>::type>()); + } + + template<int N> + struct unrolled_any + { + template <typename It, typename F> + static bool call(It const& it, F f) + { + return + f(*it) || + f(*fusion::advance_c<1>(it))|| + f(*fusion::advance_c<2>(it)) || + f(*fusion::advance_c<3>(it)) || + detail::unrolled_any<N-4>::call(fusion::advance_c<4>(it), f); + } + }; + + template<> + struct unrolled_any<3> + { + template <typename It, typename F> + static bool call(It const& it, F f) + { + return + f(*it) || + f(*fusion::advance_c<1>(it)) || + f(*fusion::advance_c<2>(it)); + } + }; + + template<> + struct unrolled_any<2> + { + template <typename It, typename F> + static bool call(It const& it, F f) + { + return + f(*it) || + f(*fusion::advance_c<1>(it)); + } + }; + + template<> + struct unrolled_any<1> + { + template <typename It, typename F> + static bool call(It const& it, F f) + { + return f(*it); + } + }; + + template<> + struct unrolled_any<0> + { + template <typename It, typename F> + static bool call(It const&, F) + { + return false; + } + }; + + template <typename Sequence, typename F> + inline bool + any(Sequence const& seq, F f, random_access_traversal_tag) + { + typedef typename result_of::begin<Sequence>::type begin; + typedef typename result_of::end<Sequence>::type end; + return detail::unrolled_any<result_of::distance<begin, end>::type::value>::call( + fusion::begin(seq), f); + } +}}} + +#endif + diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/find_if.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/find_if.hpp new file mode 100644 index 0000000..f7bae45 --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/find_if.hpp @@ -0,0 +1,252 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2007 Dan Marsden + 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) +==============================================================================*/ +#if !defined(FUSION_FIND_IF_05052005_1107) +#define FUSION_FIND_IF_05052005_1107 + +#include <boost/mpl/apply.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/lambda.hpp> +#include <boost/mpl/or.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <boost/fusion/iterator/distance.hpp> +#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/iterator/next.hpp> +#include <boost/fusion/sequence/intrinsic/begin.hpp> +#include <boost/fusion/sequence/intrinsic/end.hpp> +#include <boost/fusion/support/category_of.hpp> + +namespace boost { namespace fusion { + struct random_access_traversal_tag; +namespace detail +{ + template <typename Iterator, typename Pred> + struct apply_filter + { + typedef typename mpl::apply1< + Pred, Iterator>::type type; + BOOST_STATIC_CONSTANT(int, value = type::value); + }; + + template <typename First, typename Last, typename Pred> + struct main_find_if; + + template <typename First, typename Last, typename Pred> + struct recursive_find_if + { + typedef typename + main_find_if< + typename result_of::next<First>::type, Last, Pred + >::type + type; + }; + + template <typename First, typename Last, typename Pred> + struct main_find_if + { + typedef mpl::or_< + result_of::equal_to<First, Last> + , apply_filter<First, Pred> > + filter; + + typedef typename + mpl::eval_if< + filter + , mpl::identity<First> + , recursive_find_if<First, Last, Pred> + >::type + type; + }; + + template< + typename First, typename Last, + typename Pred, bool> + struct choose_find_if; + + template<typename First, typename Last, typename Pred> + struct choose_find_if<First, Last, Pred, false> + : main_find_if<First, Last, Pred> + {}; + + template<typename Iter, typename Pred, int n, int unrolling> + struct unroll_again; + + template <typename Iter, typename Pred, int offset> + struct apply_offset_filter + { + typedef typename result_of::advance_c<Iter, offset>::type Shifted; + typedef typename + mpl::apply1< + Pred + , Shifted + >::type + type; + BOOST_STATIC_CONSTANT(int, value = type::value); + }; + + template<typename Iter, typename Pred, int n> + struct unrolled_find_if + { + typedef typename mpl::eval_if< + apply_filter<Iter, Pred>, + mpl::identity<Iter>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 1>, + result_of::advance_c<Iter, 1>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 2>, + result_of::advance_c<Iter, 2>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 3>, + result_of::advance_c<Iter, 3>, + unroll_again< + Iter, + Pred, + n, + 4> > > > >::type type; + }; + + template<typename Iter, typename Pred> + struct unrolled_find_if<Iter, Pred, 3> + { + typedef typename mpl::eval_if< + apply_filter<Iter, Pred>, + mpl::identity<Iter>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 1>, + result_of::advance_c<Iter, 1>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 2>, + result_of::advance_c<Iter, 2>, + result_of::advance_c<Iter, 3> > > >::type type; + }; + + template<typename Iter, typename Pred> + struct unrolled_find_if<Iter, Pred, 2> + { + typedef typename mpl::eval_if< + apply_filter<Iter, Pred>, + mpl::identity<Iter>, + mpl::eval_if< + apply_offset_filter<Iter, Pred, 1>, + result_of::advance_c<Iter, 1>, + result_of::advance_c<Iter, 2> > >::type type; + }; + + template<typename Iter, typename Pred> + struct unrolled_find_if<Iter, Pred, 1> + { + typedef typename mpl::eval_if< + apply_filter<Iter, Pred>, + mpl::identity<Iter>, + result_of::advance_c<Iter, 1> >::type type; + }; + + template<typename Iter, typename Pred, int n, int unrolling> + struct unroll_again + { + typedef typename unrolled_find_if< + typename result_of::advance_c<Iter, unrolling>::type, + Pred, + n-unrolling>::type type; + }; + + template<typename Iter, typename Pred> + struct unrolled_find_if<Iter, Pred, 0> + { + typedef Iter type; + }; + + template<typename First, typename Last, typename Pred> + struct choose_find_if<First, Last, Pred, true> + { + typedef typename result_of::distance<First, Last>::type N; + typedef typename unrolled_find_if<First, Pred, N::value>::type type; + }; + + template <typename First, typename Last, typename Pred> + struct static_find_if + { + typedef typename + choose_find_if< + First + , Last + , typename mpl::lambda<Pred>::type + , is_base_of<random_access_traversal_tag, typename traits::category_of<First>::type>::value + >::type + type; + + template <typename Iterator> + static type + recursive_call(Iterator const& iter, mpl::true_) + { + return iter; + } + + template <typename Iterator> + static type + recursive_call(Iterator const& iter, mpl::false_) + { + return recursive_call(fusion::next(iter)); + } + + template <typename Iterator> + static type + recursive_call(Iterator const& iter) + { + typedef result_of::equal_to<Iterator, type> found; + return recursive_call(iter, found()); + } + + template <typename Iterator, typename Tag> + static type + choose_call(Iterator const& iter, Tag) + { + return recursive_call(iter); + } + + template <typename Iterator> + static type + choose_call(Iterator const& iter, random_access_traversal_tag) + { + typedef typename result_of::distance<Iterator, type>::type N; + return fusion::advance<N>(iter); + } + + template <typename Iterator> + static type + iter_call(Iterator const& iter) + { + return choose_call(iter, typename traits::category_of<Iterator>::type()); + } + + template <typename Sequence> + static type + call(Sequence& seq) + { + return iter_call(fusion::begin(seq)); + } + }; + + template <typename Sequence, typename Pred> + struct result_of_find_if + { + typedef + static_find_if< + typename result_of::begin<Sequence>::type + , typename result_of::end<Sequence>::type + , Pred + > + filter; + + typedef typename filter::type type; + }; +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/segmented_find.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/segmented_find.hpp new file mode 100644 index 0000000..ead5783 --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/detail/segmented_find.hpp @@ -0,0 +1,90 @@ +/*============================================================================= + 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_FIND_HPP_INCLUDED) +#define BOOST_FUSION_SEGMENTED_FIND_HPP_INCLUDED + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/fusion/algorithm/query/find_fwd.hpp> +#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/sequence/intrinsic/end.hpp> +#include <boost/fusion/support/segmented_fold_until.hpp> + +namespace boost { namespace fusion { namespace detail +{ + template <typename T> + struct segmented_find_fun + { + template <typename Sequence, typename State, typename Context> + struct apply + { + typedef + typename result_of::find<Sequence, T>::type + iterator_type; + + typedef + typename result_of::equal_to< + iterator_type + , typename result_of::end<Sequence>::type + >::type + continue_type; + + typedef + typename mpl::eval_if< + continue_type + , mpl::identity<State> + , result_of::make_segmented_iterator< + iterator_type + , Context + > + >::type + type; + + static type call(Sequence& seq, State const&state, Context const& context, segmented_find_fun) + { + return call_impl(seq, state, context, continue_type()); + } + + static type call_impl(Sequence&, State const&state, Context const&, mpl::true_) + { + return state; + } + + static type call_impl(Sequence& seq, State const&, Context const& context, mpl::false_) + { + return fusion::make_segmented_iterator(fusion::find<T>(seq), context); + } + }; + }; + + template <typename Sequence, typename T> + struct result_of_segmented_find + { + struct filter + { + typedef + typename result_of::segmented_fold_until< + Sequence + , typename result_of::end<Sequence>::type + , segmented_find_fun<T> + >::type + type; + + static type call(Sequence& seq) + { + return fusion::segmented_fold_until( + seq + , fusion::end(seq) + , detail::segmented_find_fun<T>()); + } + }; + + typedef typename filter::type type; + }; +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/find.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/find.hpp new file mode 100644 index 0000000..16def08 --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/find.hpp @@ -0,0 +1,69 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + 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(FUSION_FIND_05052005_1107) +#define FUSION_FIND_05052005_1107 + +#include <boost/fusion/algorithm/query/find_if_fwd.hpp> +#include <boost/fusion/algorithm/query/detail/find_if.hpp> +#include <boost/fusion/algorithm/query/detail/segmented_find.hpp> +#include <boost/fusion/iterator/key_of.hpp> +#include <boost/fusion/iterator/value_of.hpp> +#include <boost/fusion/support/category_of.hpp> +#include <boost/fusion/support/is_segmented.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename Sequence, typename T> + struct find + : mpl::if_< + traits::is_segmented<Sequence> + , detail::result_of_segmented_find<Sequence, T> + , detail::result_of_find_if< + Sequence, + is_same< + typename mpl::if_< + traits::is_associative<Sequence> + , key_of<mpl::_1> + , value_of<mpl::_1> + >::type + , T + > + > + >::type + {}; + } + + template <typename T, typename Sequence> + inline typename + lazy_disable_if< + is_const<Sequence> + , result_of::find<Sequence, T> + >::type const + find(Sequence& seq) + { + typedef typename result_of::find<Sequence, T>::filter filter; + return filter::call(seq); + } + + template <typename T, typename Sequence> + inline typename result_of::find<Sequence const, T>::type const + find(Sequence const& seq) + { + typedef typename result_of::find<Sequence const, T>::filter filter; + return filter::call(seq); + } +}} + +#endif diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/find_fwd.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/find_fwd.hpp new file mode 100644 index 0000000..96d989a --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/find_fwd.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + 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_FIND_FWD_HPP_INCLUDED) +#define BOOST_FUSION_FIND_FWD_HPP_INCLUDED + +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_const.hpp> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename Sequence, typename T> + struct find; + } + + template <typename T, typename Sequence> + inline typename + lazy_disable_if< + is_const<Sequence> + , result_of::find<Sequence, T> + >::type const + find(Sequence& seq); + + template <typename T, typename Sequence> + inline typename result_of::find<Sequence const, T>::type const + find(Sequence const& seq); +}} + +#endif diff --git a/3rdParty/Boost/src/boost/fusion/algorithm/query/find_if_fwd.hpp b/3rdParty/Boost/src/boost/fusion/algorithm/query/find_if_fwd.hpp new file mode 100644 index 0000000..adb8f2d --- /dev/null +++ b/3rdParty/Boost/src/boost/fusion/algorithm/query/find_if_fwd.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + 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_FIND_IF_FWD_HPP_INCLUDED) +#define BOOST_FUSION_FIND_IF_FWD_HPP_INCLUDED + +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_const.hpp> + +// Forward declaration of find_if algorithm +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename Sequence, typename Pred> + struct find_if; + } + + template <typename Pred, typename Sequence> + typename + lazy_disable_if< + is_const<Sequence> + , result_of::find_if<Sequence, Pred> + >::type + find_if(Sequence& seq); + + template <typename Pred, typename Sequence> + typename result_of::find_if<Sequence const, Pred>::type const + find_if(Sequence const& seq); +}} + +#endif |