1
//-----------------------------------------------------------------------------
2
// boost mpl/upper_bound.hpp header file
3
// See http://www.boost.org for updates, documentation, and revision history.
4
//-----------------------------------------------------------------------------
6
// Copyright (c) 2001-02
9
// Permission to use, copy, modify, distribute and sell this software
10
// and its documentation for any purpose is hereby granted without fee,
11
// provided that the above copyright notice appears in all copies and
12
// that both the copyright notice and this permission notice appear in
13
// supporting documentation. No representations are made about the
14
// suitability of this software for any purpose. It is provided "as is"
15
// without express or implied warranty.
17
#ifndef BOOST_MPL_UPPER_BOUND_HPP_INCLUDED
18
#define BOOST_MPL_UPPER_BOUND_HPP_INCLUDED
20
#include "boost/mpl/less.hpp"
21
#include "boost/mpl/lambda.hpp"
22
#include "boost/mpl/aux_/void_spec.hpp"
24
#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x561 || !defined(BOOST_STRICT_CONFIG))
25
# define BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL
28
#if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL)
29
# include "boost/mpl/minus.hpp"
30
# include "boost/mpl/divides.hpp"
31
# include "boost/mpl/size.hpp"
32
# include "boost/mpl/advance.hpp"
33
# include "boost/mpl/begin_end.hpp"
34
# include "boost/mpl/integral_c.hpp"
35
# include "boost/mpl/int.hpp"
36
# include "boost/mpl/apply_if.hpp"
37
# include "boost/mpl/apply.hpp"
38
# include "boost/mpl/aux_/apply.hpp"
39
# include "boost/mpl/aux_/deref_wknd.hpp"
40
# include "boost/mpl/aux_/value_wknd.hpp"
42
# include "boost/mpl/find.hpp"
43
# include "boost/mpl/bind.hpp"
46
#include "boost/config.hpp"
51
#if defined(BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL)
53
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
55
// agurt 23/oct/02: has a wrong complexity etc., but at least it works;
56
// feel free to contribute a better implementation!
58
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
59
, typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T)
60
, typename Predicate = less<>
61
, typename pred_ = typename lambda<Predicate>::type
64
: find_if< Sequence, bind2<pred_,T,_> >
68
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
78
, typename DeferredIterator
80
struct upper_bound_step_impl;
86
, typename DeferredIterator
88
struct upper_bound_step
90
typedef typename apply_if<
92
, upper_bound_step_impl<Distance,Predicate,T,DeferredIterator>
93
, apply0<DeferredIterator>
101
, typename DeferredIterator
103
struct upper_bound_step_impl
105
typedef typename divides< Distance, integral_c<long,2> >::type offset_;
106
typedef typename DeferredIterator::type iter_;
107
typedef typename advance< iter_,offset_ >::type middle_;
108
typedef typename BOOST_MPL_AUX_APPLY2(
111
, typename BOOST_MPL_AUX_DEREF_WNKD(middle_)
114
typedef typename minus< Distance, offset_, integral_c<long,1> >::type step_;
115
typedef upper_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
116
typedef upper_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
117
typedef typename apply_if<
126
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
129
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
130
, typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T)
131
, typename Predicate = less<>
136
typedef typename lambda<Predicate>::type pred_;
137
typedef typename size<Sequence>::type size_;
140
typedef typename aux::upper_bound_step<
141
size_,pred_,T,begin<Sequence>
145
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
147
#endif // BOOST_MPL_CFG_STRIPPED_DOWN_UPPER_BOUND_IMPL
149
BOOST_MPL_AUX_ALGORITHM_VOID_SPEC(2, upper_bound)
154
#endif // BOOST_MPL_UPPER_BOUND_HPP_INCLUDED