Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Range v3 library
0002 //
0003 //  Copyright 2019 Christopher Di Bella
0004 //
0005 //  Use, modification and distribution is subject to the
0006 //  Boost Software License, Version 1.0. (See accompanying
0007 //  file LICENSE_1_0.txt or copy at
0008 //  http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 // Project home: https://github.com/ericniebler/range-v3
0011 #ifndef RANGES_V3_ALGORITHM_STARTS_WITH_HPP
0012 #define RANGES_V3_ALGORITHM_STARTS_WITH_HPP
0013 
0014 #include <utility>
0015 
0016 #include <range/v3/range_fwd.hpp>
0017 
0018 #include <range/v3/algorithm/equal.hpp>
0019 #include <range/v3/algorithm/mismatch.hpp>
0020 #include <range/v3/functional/comparisons.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/iterator/concepts.hpp>
0023 #include <range/v3/iterator/operations.hpp>
0024 #include <range/v3/range/access.hpp>
0025 #include <range/v3/range/concepts.hpp>
0026 #include <range/v3/range/traits.hpp>
0027 #include <range/v3/utility/static_const.hpp>
0028 
0029 #include <range/v3/detail/prologue.hpp>
0030 
0031 namespace ranges
0032 {
0033     /// \addtogroup group-algorithms
0034     /// @{
0035 
0036     // template<typename I1, typename I2>
0037     // struct starts_with_result : detail::in1_in2_result<I1, I2>
0038     // {
0039     //     bool result;
0040     // };
0041 
0042     RANGES_FUNC_BEGIN(starts_with)
0043 
0044         /// \brief function template \c starts_with
0045         template(typename I1,
0046                  typename S1,
0047                  typename I2,
0048                  typename S2,
0049                  typename Comp = equal_to,
0050                  typename Proj1 = identity,
0051                  typename Proj2 = identity)(
0052             requires input_iterator<I1> AND sentinel_for<S1, I1> AND
0053                 input_iterator<I2> AND sentinel_for<S2, I2> AND
0054                 indirectly_comparable<I1, I2, Comp, Proj1, Proj2>)
0055         constexpr bool RANGES_FUNC(starts_with)(I1 first1,
0056                                                 S1 last1,
0057                                                 I2 first2,
0058                                                 S2 last2,
0059                                                 Comp comp = {},
0060                                                 Proj1 proj1 = {},
0061                                                 Proj2 proj2 = {}) //
0062         {
0063             return mismatch(std::move(first1),
0064                             std::move(last1),
0065                             std::move(first2),
0066                             last2,
0067                             std::move(comp),
0068                             std::move(proj1),
0069                             std::move(proj2))
0070                        .in2 == last2;
0071         }
0072 
0073         /// \overload
0074         template(typename R1,
0075                  typename R2,
0076                  typename Comp = equal_to,
0077                  typename Proj1 = identity,
0078                  typename Proj2 = identity)(
0079             requires input_range<R1> AND input_range<R2> AND
0080                 indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Comp, Proj1, Proj2>)
0081         constexpr bool RANGES_FUNC(starts_with)(
0082             R1 && r1, R2 && r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) //
0083         {
0084             return (*this)( //
0085                 begin(r1),
0086                 end(r1),
0087                 begin(r2),
0088                 end(r2),
0089                 std::move(comp),
0090                 std::move(proj1),
0091                 std::move(proj2));
0092         }
0093 
0094     RANGES_FUNC_END(starts_with)
0095     /// @}
0096 } // namespace ranges
0097 
0098 #include <range/v3/detail/epilogue.hpp>
0099 
0100 #endif // RANGES_V3_ALGORITHM_STARTS_WITH_HPP