os/ossrv/ossrv_pub/boost_apis/boost/mpl/lower_bound.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/mpl/lower_bound.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,143 @@
     1.4 +
     1.5 +#ifndef BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
     1.6 +#define BOOST_MPL_LOWER_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/lower_bound.hpp,v $
    1.17 +// $Date: 2004/09/02 15:40:41 $
    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_LOWER_BOUND_IMPL
    1.27 +#endif
    1.28 +
    1.29 +#if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_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/not.hpp>
    1.43 +#   include <boost/mpl/find.hpp>
    1.44 +#   include <boost/mpl/bind.hpp>
    1.45 +#endif
    1.46 +
    1.47 +#include <boost/config.hpp>
    1.48 +
    1.49 +namespace boost { namespace mpl {
    1.50 +
    1.51 +#if defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
    1.52 +
    1.53 +// agurt 23/oct/02: has a wrong complexity etc., but at least it works
    1.54 +// feel free to contribute a better implementation!
    1.55 +template<
    1.56 +      typename BOOST_MPL_AUX_NA_PARAM(Sequence)
    1.57 +    , typename BOOST_MPL_AUX_NA_PARAM(T)
    1.58 +    , typename Predicate = less<>
    1.59 +    , typename pred_ = typename lambda<Predicate>::type
    1.60 +    >
    1.61 +struct lower_bound
    1.62 +    : find_if< Sequence, bind1< not_<>, bind2<pred_,_,T> > >
    1.63 +{
    1.64 +};
    1.65 +
    1.66 +#else
    1.67 +
    1.68 +namespace aux {
    1.69 +
    1.70 +template<
    1.71 +      typename Distance
    1.72 +    , typename Predicate
    1.73 +    , typename T
    1.74 +    , typename DeferredIterator
    1.75 +    >
    1.76 +struct lower_bound_step_impl;
    1.77 +
    1.78 +template< 
    1.79 +      typename Distance
    1.80 +    , typename Predicate
    1.81 +    , typename T
    1.82 +    , typename DeferredIterator
    1.83 +    >
    1.84 +struct lower_bound_step
    1.85 +{
    1.86 +    typedef typename eval_if<
    1.87 +          Distance
    1.88 +        , lower_bound_step_impl<Distance,Predicate,T,DeferredIterator>
    1.89 +        , DeferredIterator
    1.90 +        >::type type;
    1.91 +};
    1.92 +    
    1.93 +template<
    1.94 +      typename Distance
    1.95 +    , typename Predicate
    1.96 +    , typename T
    1.97 +    , typename DeferredIterator
    1.98 +    >
    1.99 +struct lower_bound_step_impl
   1.100 +{
   1.101 +    typedef typename divides< Distance, long_<2> >::type offset_;
   1.102 +    typedef typename DeferredIterator::type iter_;
   1.103 +    typedef typename advance< iter_,offset_ >::type middle_;
   1.104 +    typedef typename apply2<
   1.105 +              Predicate
   1.106 +            , typename deref<middle_>::type
   1.107 +            , T
   1.108 +            >::type cond_;
   1.109 +
   1.110 +    typedef typename prior< minus< Distance, offset_> >::type step_;
   1.111 +    typedef lower_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
   1.112 +    typedef lower_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
   1.113 +    typedef typename eval_if<
   1.114 +          cond_
   1.115 +        , step_backward_
   1.116 +        , step_forward_
   1.117 +        >::type type;
   1.118 +};
   1.119 +
   1.120 +
   1.121 +} // namespace aux
   1.122 +
   1.123 +template<
   1.124 +      typename BOOST_MPL_AUX_NA_PARAM(Sequence)
   1.125 +    , typename BOOST_MPL_AUX_NA_PARAM(T)
   1.126 +    , typename Predicate = less<>
   1.127 +    >
   1.128 +struct lower_bound
   1.129 +{
   1.130 + private:
   1.131 +    typedef typename lambda<Predicate>::type pred_;
   1.132 +    typedef typename size<Sequence>::type size_;
   1.133 +
   1.134 + public:
   1.135 +    typedef typename aux::lower_bound_step<
   1.136 +        size_,pred_,T,begin<Sequence>
   1.137 +        >::type type;
   1.138 +};
   1.139 +
   1.140 +#endif // BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
   1.141 +
   1.142 +BOOST_MPL_AUX_NA_SPEC(2, lower_bound)
   1.143 +
   1.144 +}}
   1.145 +
   1.146 +#endif // BOOST_MPL_LOWER_BOUND_HPP_INCLUDED