File indexing completed on 2025-01-18 09:41:56
0001
0002 #ifndef BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
0003 #define BOOST_MPL_LOWER_BOUND_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <boost/mpl/less.hpp>
0018 #include <boost/mpl/lambda.hpp>
0019 #include <boost/mpl/aux_/na_spec.hpp>
0020 #include <boost/mpl/aux_/config/workaround.hpp>
0021
0022 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610))
0023 # define BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL
0024 #endif
0025
0026 #if !defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
0027 # include <boost/mpl/minus.hpp>
0028 # include <boost/mpl/divides.hpp>
0029 # include <boost/mpl/size.hpp>
0030 # include <boost/mpl/advance.hpp>
0031 # include <boost/mpl/begin_end.hpp>
0032 # include <boost/mpl/long.hpp>
0033 # include <boost/mpl/eval_if.hpp>
0034 # include <boost/mpl/prior.hpp>
0035 # include <boost/mpl/deref.hpp>
0036 # include <boost/mpl/apply.hpp>
0037 # include <boost/mpl/aux_/value_wknd.hpp>
0038 #else
0039 # include <boost/mpl/not.hpp>
0040 # include <boost/mpl/find.hpp>
0041 # include <boost/mpl/bind.hpp>
0042 #endif
0043
0044 #include <boost/config.hpp>
0045
0046 namespace boost { namespace mpl {
0047
0048 #if defined(BOOST_MPL_CFG_STRIPPED_DOWN_LOWER_BOUND_IMPL)
0049
0050
0051
0052 template<
0053 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
0054 , typename BOOST_MPL_AUX_NA_PARAM(T)
0055 , typename Predicate = less<>
0056 , typename pred_ = typename lambda<Predicate>::type
0057 >
0058 struct lower_bound
0059 : find_if< Sequence, bind1< not_<>, bind2<pred_,_,T> > >
0060 {
0061 };
0062
0063 #else
0064
0065 namespace aux {
0066
0067 template<
0068 typename Distance
0069 , typename Predicate
0070 , typename T
0071 , typename DeferredIterator
0072 >
0073 struct lower_bound_step_impl;
0074
0075 template<
0076 typename Distance
0077 , typename Predicate
0078 , typename T
0079 , typename DeferredIterator
0080 >
0081 struct lower_bound_step
0082 {
0083 typedef typename eval_if<
0084 Distance
0085 , lower_bound_step_impl<Distance,Predicate,T,DeferredIterator>
0086 , DeferredIterator
0087 >::type type;
0088 };
0089
0090 template<
0091 typename Distance
0092 , typename Predicate
0093 , typename T
0094 , typename DeferredIterator
0095 >
0096 struct lower_bound_step_impl
0097 {
0098 typedef typename divides< Distance, long_<2> >::type offset_;
0099 typedef typename DeferredIterator::type iter_;
0100 typedef typename advance< iter_,offset_ >::type middle_;
0101 typedef typename apply2<
0102 Predicate
0103 , typename deref<middle_>::type
0104 , T
0105 >::type cond_;
0106
0107 typedef typename prior< minus< Distance, offset_> >::type step_;
0108 typedef lower_bound_step< offset_,Predicate,T,DeferredIterator > step_forward_;
0109 typedef lower_bound_step< step_,Predicate,T,next<middle_> > step_backward_;
0110 typedef typename eval_if<
0111 cond_
0112 , step_backward_
0113 , step_forward_
0114 >::type type;
0115 };
0116
0117
0118 }
0119
0120 template<
0121 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
0122 , typename BOOST_MPL_AUX_NA_PARAM(T)
0123 , typename Predicate = less<>
0124 >
0125 struct lower_bound
0126 {
0127 private:
0128 typedef typename lambda<Predicate>::type pred_;
0129 typedef typename size<Sequence>::type size_;
0130
0131 public:
0132 typedef typename aux::lower_bound_step<
0133 size_,pred_,T,begin<Sequence>
0134 >::type type;
0135 };
0136
0137 #endif
0138
0139 BOOST_MPL_AUX_NA_SPEC(2, lower_bound)
0140
0141 }}
0142
0143 #endif