1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/mpl/upper_bound.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,141 @@
1.4 +
1.5 +#ifndef BOOST_MPL_UPPER_BOUND_HPP_INCLUDED
1.6 +#define BOOST_MPL_UPPER_BOUND_HPP_INCLUDED
1.7 +
1.8 +// Copyright Aleksey Gurtovoy 2001-2004
1.9 +//
1.10 +// Distributed under the Boost Software License, Version 1.0.
1.11 +// (See accompanying file LICENSE_1_0.txt or copy at
1.12 +// http://www.boost.org/LICENSE_1_0.txt)
1.13 +//
1.14 +// See http://www.boost.org/libs/mpl for documentation.
1.15 +
1.16 +// $Source: /cvsroot/boost/boost/boost/mpl/upper_bound.hpp,v $
1.17 +// $Date: 2004/09/02 15:40:42 $
1.18 +// $Revision: 1.8 $
1.19 +
1.20 +#include <boost/mpl/less.hpp>
1.21 +#include <boost/mpl/lambda.hpp>
1.22 +#include <boost/mpl/aux_/na_spec.hpp>
1.23 +#include <boost/mpl/aux_/config/workaround.hpp>
1.24 +
1.25 +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
1.26 +# define BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL
1.27 +#endif
1.28 +
1.29 +#if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL)
1.30 +# include <boost/mpl/minus.hpp>
1.31 +# include <boost/mpl/divides.hpp>
1.32 +# include <boost/mpl/size.hpp>
1.33 +# include <boost/mpl/advance.hpp>
1.34 +# include <boost/mpl/begin_end.hpp>
1.35 +# include <boost/mpl/long.hpp>
1.36 +# include <boost/mpl/eval_if.hpp>
1.37 +# include <boost/mpl/prior.hpp>
1.38 +# include <boost/mpl/deref.hpp>
1.39 +# include <boost/mpl/apply.hpp>
1.40 +# include <boost/mpl/aux_/value_wknd.hpp>
1.41 +#else
1.42 +# include <boost/mpl/find.hpp>
1.43 +# include <boost/mpl/bind.hpp>
1.44 +#endif
1.45 +
1.46 +#include <boost/config.hpp>
1.47 +
1.48 +namespace boost { namespace mpl {
1.49 +
1.50 +#if defined(BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL)
1.51 +
1.52 +// agurt 23/oct/02: has a wrong complexity etc., but at least it works;
1.53 +// feel free to contribute a better implementation!
1.54 +template<
1.55 + typename BOOST_MPL_AUX_NA_PARAM(Sequence)
1.56 + , typename BOOST_MPL_AUX_NA_PARAM(T)
1.57 + , typename Predicate = less<>
1.58 + , typename pred_ = typename lambda<Predicate>::type
1.59 + >
1.60 +struct upper_bound
1.61 + : find_if< Sequence, bind2<pred_,T,_> >
1.62 +{
1.63 +};
1.64 +
1.65 +#else
1.66 +
1.67 +namespace aux {
1.68 +
1.69 +template<
1.70 + typename Distance
1.71 + , typename Predicate
1.72 + , typename T
1.73 + , typename DeferredIterator
1.74 + >
1.75 +struct upper_bound_step_impl;
1.76 +
1.77 +template<
1.78 + typename Distance
1.79 + , typename Predicate
1.80 + , typename T
1.81 + , typename DeferredIterator
1.82 + >
1.83 +struct upper_bound_step
1.84 +{
1.85 + typedef typename eval_if<
1.86 + Distance
1.87 + , upper_bound_step_impl<Distance,Predicate,T,DeferredIterator>
1.88 + , DeferredIterator
1.89 + >::type type;
1.90 +};
1.91 +
1.92 +template<
1.93 + typename Distance
1.94 + , typename Predicate
1.95 + , typename T
1.96 + , typename DeferredIterator
1.97 + >
1.98 +struct upper_bound_step_impl
1.99 +{
1.100 + typedef typename divides< Distance, long_<2> >::type offset_;
1.101 + typedef typename DeferredIterator::type iter_;
1.102 + typedef typename advance< iter_,offset_ >::type middle_;
1.103 + typedef typename apply2<
1.104 + Predicate
1.105 + , T
1.106 + , typename deref<middle_>::type
1.107 + >::type cond_;
1.108 +
1.109 + typedef typename prior< minus< Distance, offset_ > >::type step_;
1.110 + typedef upper_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
1.111 + typedef upper_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
1.112 + typedef typename eval_if<
1.113 + cond_
1.114 + , step_forward_
1.115 + , step_backward_
1.116 + >::type type;
1.117 +};
1.118 +
1.119 +} // namespace aux
1.120 +
1.121 +template<
1.122 + typename BOOST_MPL_AUX_NA_PARAM(Sequence)
1.123 + , typename BOOST_MPL_AUX_NA_PARAM(T)
1.124 + , typename Predicate = less<>
1.125 + >
1.126 +struct upper_bound
1.127 +{
1.128 + private:
1.129 + typedef typename lambda<Predicate>::type pred_;
1.130 + typedef typename size<Sequence>::type size_;
1.131 +
1.132 + public:
1.133 + typedef typename aux::upper_bound_step<
1.134 + size_,pred_,T,begin<Sequence>
1.135 + >::type type;
1.136 +};
1.137 +
1.138 +#endif // BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL
1.139 +
1.140 +BOOST_MPL_AUX_NA_SPEC(2, upper_bound)
1.141 +
1.142 +}}
1.143 +
1.144 +#endif // BOOST_MPL_UPPER_BOUND_HPP_INCLUDED