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