2 #ifndef BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
\r
3 #define BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
\r
5 // Copyright Aleksey Gurtovoy 2001-2004
\r
7 // Distributed under the Boost Software License, Version 1.0.
\r
8 // (See accompanying file LICENSE_1_0.txt or copy at
\r
9 // http://www.boost.org/LICENSE_1_0.txt)
\r
11 // See http://www.boost.org/libs/mpl for documentation.
\r
13 // $Id: lower_bound.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
\r
14 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
\r
15 // $Revision: 49267 $
\r
17 #include <boost/mpl/less.hpp>
\r
18 #include <boost/mpl/lambda.hpp>
\r
19 #include <boost/mpl/aux_/na_spec.hpp>
\r
20 #include <boost/mpl/aux_/config/workaround.hpp>
\r
22 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610))
\r
23 # define BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
\r
26 #if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
\r
27 # include <boost/mpl/minus.hpp>
\r
28 # include <boost/mpl/divides.hpp>
\r
29 # include <boost/mpl/size.hpp>
\r
30 # include <boost/mpl/advance.hpp>
\r
31 # include <boost/mpl/begin_end.hpp>
\r
32 # include <boost/mpl/long.hpp>
\r
33 # include <boost/mpl/eval_if.hpp>
\r
34 # include <boost/mpl/prior.hpp>
\r
35 # include <boost/mpl/deref.hpp>
\r
36 # include <boost/mpl/apply.hpp>
\r
37 # include <boost/mpl/aux_/value_wknd.hpp>
\r
39 # include <boost/mpl/not.hpp>
\r
40 # include <boost/mpl/find.hpp>
\r
41 # include <boost/mpl/bind.hpp>
\r
44 #include <boost/config.hpp>
\r
46 namespace boost { namespace mpl {
\r
48 #if defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
\r
50 // agurt 23/oct/02: has a wrong complexity etc., but at least it works
\r
51 // feel free to contribute a better implementation!
\r
53 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
\r
54 , typename BOOST_MPL_AUX_NA_PARAM(T)
\r
55 , typename Predicate = less<>
\r
56 , typename pred_ = typename lambda<Predicate>::type
\r
59 : find_if< Sequence, bind1< not_<>, bind2<pred_,_,T> > >
\r
69 , typename Predicate
\r
71 , typename DeferredIterator
\r
73 struct lower_bound_step_impl;
\r
77 , typename Predicate
\r
79 , typename DeferredIterator
\r
81 struct lower_bound_step
\r
83 typedef typename eval_if<
\r
85 , lower_bound_step_impl<Distance,Predicate,T,DeferredIterator>
\r
92 , typename Predicate
\r
94 , typename DeferredIterator
\r
96 struct lower_bound_step_impl
\r
98 typedef typename divides< Distance, long_<2> >::type offset_;
\r
99 typedef typename DeferredIterator::type iter_;
\r
100 typedef typename advance< iter_,offset_ >::type middle_;
\r
101 typedef typename apply2<
\r
103 , typename deref<middle_>::type
\r
107 typedef typename prior< minus< Distance, offset_> >::type step_;
\r
108 typedef lower_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
\r
109 typedef lower_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
\r
110 typedef typename eval_if<
\r
121 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
\r
122 , typename BOOST_MPL_AUX_NA_PARAM(T)
\r
123 , typename Predicate = less<>
\r
128 typedef typename lambda<Predicate>::type pred_;
\r
129 typedef typename size<Sequence>::type size_;
\r
132 typedef typename aux::lower_bound_step<
\r
133 size_,pred_,T,begin<Sequence>
\r
137 #endif // BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
\r
139 BOOST_MPL_AUX_NA_SPEC(2, lower_bound)
\r
143 #endif // BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
\r