sl@0
|
1 |
|
sl@0
|
2 |
#ifndef BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
|
sl@0
|
3 |
#define BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
|
sl@0
|
4 |
|
sl@0
|
5 |
// Copyright Aleksey Gurtovoy 2001-2004
|
sl@0
|
6 |
//
|
sl@0
|
7 |
// Distributed under the Boost Software License, Version 1.0.
|
sl@0
|
8 |
// (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
9 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// See http://www.boost.org/libs/mpl for documentation.
|
sl@0
|
12 |
|
sl@0
|
13 |
// $Source: /cvsroot/boost/boost/boost/mpl/lower_bound.hpp,v $
|
sl@0
|
14 |
// $Date: 2004/09/02 15:40:41 $
|
sl@0
|
15 |
// $Revision: 1.8 $
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <boost/mpl/less.hpp>
|
sl@0
|
18 |
#include <boost/mpl/lambda.hpp>
|
sl@0
|
19 |
#include <boost/mpl/aux_/na_spec.hpp>
|
sl@0
|
20 |
#include <boost/mpl/aux_/config/workaround.hpp>
|
sl@0
|
21 |
|
sl@0
|
22 |
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
sl@0
|
23 |
# define BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
|
sl@0
|
24 |
#endif
|
sl@0
|
25 |
|
sl@0
|
26 |
#if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
|
sl@0
|
27 |
# include <boost/mpl/minus.hpp>
|
sl@0
|
28 |
# include <boost/mpl/divides.hpp>
|
sl@0
|
29 |
# include <boost/mpl/size.hpp>
|
sl@0
|
30 |
# include <boost/mpl/advance.hpp>
|
sl@0
|
31 |
# include <boost/mpl/begin_end.hpp>
|
sl@0
|
32 |
# include <boost/mpl/long.hpp>
|
sl@0
|
33 |
# include <boost/mpl/eval_if.hpp>
|
sl@0
|
34 |
# include <boost/mpl/prior.hpp>
|
sl@0
|
35 |
# include <boost/mpl/deref.hpp>
|
sl@0
|
36 |
# include <boost/mpl/apply.hpp>
|
sl@0
|
37 |
# include <boost/mpl/aux_/value_wknd.hpp>
|
sl@0
|
38 |
#else
|
sl@0
|
39 |
# include <boost/mpl/not.hpp>
|
sl@0
|
40 |
# include <boost/mpl/find.hpp>
|
sl@0
|
41 |
# include <boost/mpl/bind.hpp>
|
sl@0
|
42 |
#endif
|
sl@0
|
43 |
|
sl@0
|
44 |
#include <boost/config.hpp>
|
sl@0
|
45 |
|
sl@0
|
46 |
namespace boost { namespace mpl {
|
sl@0
|
47 |
|
sl@0
|
48 |
#if defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
|
sl@0
|
49 |
|
sl@0
|
50 |
// agurt 23/oct/02: has a wrong complexity etc., but at least it works
|
sl@0
|
51 |
// feel free to contribute a better implementation!
|
sl@0
|
52 |
template<
|
sl@0
|
53 |
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
sl@0
|
54 |
, typename BOOST_MPL_AUX_NA_PARAM(T)
|
sl@0
|
55 |
, typename Predicate = less<>
|
sl@0
|
56 |
, typename pred_ = typename lambda<Predicate>::type
|
sl@0
|
57 |
>
|
sl@0
|
58 |
struct lower_bound
|
sl@0
|
59 |
: find_if< Sequence, bind1< not_<>, bind2<pred_,_,T> > >
|
sl@0
|
60 |
{
|
sl@0
|
61 |
};
|
sl@0
|
62 |
|
sl@0
|
63 |
#else
|
sl@0
|
64 |
|
sl@0
|
65 |
namespace aux {
|
sl@0
|
66 |
|
sl@0
|
67 |
template<
|
sl@0
|
68 |
typename Distance
|
sl@0
|
69 |
, typename Predicate
|
sl@0
|
70 |
, typename T
|
sl@0
|
71 |
, typename DeferredIterator
|
sl@0
|
72 |
>
|
sl@0
|
73 |
struct lower_bound_step_impl;
|
sl@0
|
74 |
|
sl@0
|
75 |
template<
|
sl@0
|
76 |
typename Distance
|
sl@0
|
77 |
, typename Predicate
|
sl@0
|
78 |
, typename T
|
sl@0
|
79 |
, typename DeferredIterator
|
sl@0
|
80 |
>
|
sl@0
|
81 |
struct lower_bound_step
|
sl@0
|
82 |
{
|
sl@0
|
83 |
typedef typename eval_if<
|
sl@0
|
84 |
Distance
|
sl@0
|
85 |
, lower_bound_step_impl<Distance,Predicate,T,DeferredIterator>
|
sl@0
|
86 |
, DeferredIterator
|
sl@0
|
87 |
>::type type;
|
sl@0
|
88 |
};
|
sl@0
|
89 |
|
sl@0
|
90 |
template<
|
sl@0
|
91 |
typename Distance
|
sl@0
|
92 |
, typename Predicate
|
sl@0
|
93 |
, typename T
|
sl@0
|
94 |
, typename DeferredIterator
|
sl@0
|
95 |
>
|
sl@0
|
96 |
struct lower_bound_step_impl
|
sl@0
|
97 |
{
|
sl@0
|
98 |
typedef typename divides< Distance, long_<2> >::type offset_;
|
sl@0
|
99 |
typedef typename DeferredIterator::type iter_;
|
sl@0
|
100 |
typedef typename advance< iter_,offset_ >::type middle_;
|
sl@0
|
101 |
typedef typename apply2<
|
sl@0
|
102 |
Predicate
|
sl@0
|
103 |
, typename deref<middle_>::type
|
sl@0
|
104 |
, T
|
sl@0
|
105 |
>::type cond_;
|
sl@0
|
106 |
|
sl@0
|
107 |
typedef typename prior< minus< Distance, offset_> >::type step_;
|
sl@0
|
108 |
typedef lower_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
|
sl@0
|
109 |
typedef lower_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
|
sl@0
|
110 |
typedef typename eval_if<
|
sl@0
|
111 |
cond_
|
sl@0
|
112 |
, step_backward_
|
sl@0
|
113 |
, step_forward_
|
sl@0
|
114 |
>::type type;
|
sl@0
|
115 |
};
|
sl@0
|
116 |
|
sl@0
|
117 |
|
sl@0
|
118 |
} // namespace aux
|
sl@0
|
119 |
|
sl@0
|
120 |
template<
|
sl@0
|
121 |
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
sl@0
|
122 |
, typename BOOST_MPL_AUX_NA_PARAM(T)
|
sl@0
|
123 |
, typename Predicate = less<>
|
sl@0
|
124 |
>
|
sl@0
|
125 |
struct lower_bound
|
sl@0
|
126 |
{
|
sl@0
|
127 |
private:
|
sl@0
|
128 |
typedef typename lambda<Predicate>::type pred_;
|
sl@0
|
129 |
typedef typename size<Sequence>::type size_;
|
sl@0
|
130 |
|
sl@0
|
131 |
public:
|
sl@0
|
132 |
typedef typename aux::lower_bound_step<
|
sl@0
|
133 |
size_,pred_,T,begin<Sequence>
|
sl@0
|
134 |
>::type type;
|
sl@0
|
135 |
};
|
sl@0
|
136 |
|
sl@0
|
137 |
#endif // BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
|
sl@0
|
138 |
|
sl@0
|
139 |
BOOST_MPL_AUX_NA_SPEC(2, lower_bound)
|
sl@0
|
140 |
|
sl@0
|
141 |
}}
|
sl@0
|
142 |
|
sl@0
|
143 |
#endif // BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
|