Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:52

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2014-present
0005 //  Copyright Casey Carter 2016
0006 //
0007 //  Use, modification and distribution is subject to the
0008 //  Boost Software License, Version 1.0. (See accompanying
0009 //  file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // Project home: https://github.com/ericniebler/range-v3
0013 //
0014 #ifndef RANGES_V3_ALGORITHM_AUX_LOWER_BOUND_N_HPP
0015 #define RANGES_V3_ALGORITHM_AUX_LOWER_BOUND_N_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/algorithm/aux_/partition_point_n.hpp>
0020 #include <range/v3/functional/comparisons.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/iterator/traits.hpp>
0024 #include <range/v3/utility/static_const.hpp>
0025 
0026 #include <range/v3/detail/prologue.hpp>
0027 
0028 namespace ranges
0029 {
0030     /// \cond
0031     namespace detail
0032     {
0033         // [&](auto&& i){ return invoke(pred, i, val); }
0034         template<typename Pred, typename Val>
0035         struct lower_bound_predicate
0036         {
0037             Pred & pred_;
0038             Val & val_;
0039 
0040             template<typename T>
0041             constexpr bool operator()(T && t) const
0042             {
0043                 return invoke(pred_, static_cast<T &&>(t), val_);
0044             }
0045         };
0046 
0047         template<typename Pred, typename Val>
0048         constexpr lower_bound_predicate<Pred, Val> make_lower_bound_predicate(Pred & pred,
0049                                                                               Val & val)
0050         {
0051             return {pred, val};
0052         }
0053     } // namespace detail
0054     /// \endcond
0055 
0056     namespace aux
0057     {
0058         struct lower_bound_n_fn
0059         {
0060             template(typename I, typename V, typename C = less, typename P = identity)(
0061                 requires forward_iterator<I> AND
0062                     indirect_strict_weak_order<C, V const *, projected<I, P>>)
0063             constexpr I operator()(I first,
0064                                    iter_difference_t<I> d,
0065                                    V const & val,
0066                                    C pred = C{},
0067                                    P proj = P{}) const
0068             {
0069                 return partition_point_n(std::move(first),
0070                                          d,
0071                                          detail::make_lower_bound_predicate(pred, val),
0072                                          std::move(proj));
0073             }
0074         };
0075 
0076         RANGES_INLINE_VARIABLE(lower_bound_n_fn, lower_bound_n)
0077     } // namespace aux
0078 } // namespace ranges
0079 
0080 #include <range/v3/detail/epilogue.hpp>
0081 
0082 #endif