120517557Szijunzhao //===----------------------------------------------------------------------===// 220517557Szijunzhao // 320517557Szijunzhao // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 420517557Szijunzhao // See https://llvm.org/LICENSE.txt for license information. 520517557Szijunzhao // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 620517557Szijunzhao // 720517557Szijunzhao //===----------------------------------------------------------------------===// 820517557Szijunzhao 920517557Szijunzhao #ifndef _LIBCPP___ALGORITHM_RANGES_STARTS_WITH_H 1020517557Szijunzhao #define _LIBCPP___ALGORITHM_RANGES_STARTS_WITH_H 1120517557Szijunzhao 1220517557Szijunzhao #include <__algorithm/in_in_result.h> 1379f852ccSLouis Dionne #include <__algorithm/ranges_mismatch.h> 1420517557Szijunzhao #include <__config> 1520517557Szijunzhao #include <__functional/identity.h> 1620517557Szijunzhao #include <__functional/ranges_operations.h> 1720517557Szijunzhao #include <__iterator/concepts.h> 1820517557Szijunzhao #include <__iterator/indirectly_comparable.h> 1920517557Szijunzhao #include <__ranges/access.h> 2020517557Szijunzhao #include <__ranges/concepts.h> 2120517557Szijunzhao #include <__utility/move.h> 2220517557Szijunzhao 2320517557Szijunzhao #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2420517557Szijunzhao # pragma GCC system_header 2520517557Szijunzhao #endif 2620517557Szijunzhao 277b462251SLouis Dionne _LIBCPP_PUSH_MACROS 287b462251SLouis Dionne #include <__undef_macros> 297b462251SLouis Dionne 3020517557Szijunzhao #if _LIBCPP_STD_VER >= 23 3120517557Szijunzhao 3220517557Szijunzhao _LIBCPP_BEGIN_NAMESPACE_STD 3320517557Szijunzhao 3420517557Szijunzhao namespace ranges { 35*d10dc5a0SChristopher Di Bella struct __starts_with { 3620517557Szijunzhao template <input_iterator _Iter1, 3720517557Szijunzhao sentinel_for<_Iter1> _Sent1, 3820517557Szijunzhao input_iterator _Iter2, 3920517557Szijunzhao sentinel_for<_Iter2> _Sent2, 4020517557Szijunzhao class _Pred = ranges::equal_to, 4120517557Szijunzhao class _Proj1 = identity, 4220517557Szijunzhao class _Proj2 = identity> 4320517557Szijunzhao requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> 4483bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()( 4520517557Szijunzhao _Iter1 __first1, 4620517557Szijunzhao _Sent1 __last1, 4720517557Szijunzhao _Iter2 __first2, 4820517557Szijunzhao _Sent2 __last2, 4920517557Szijunzhao _Pred __pred = {}, 5020517557Szijunzhao _Proj1 __proj1 = {}, 51c3747883SXiaoyang Liu _Proj2 __proj2 = {}) { 52*d10dc5a0SChristopher Di Bella return __mismatch::__go( 5320517557Szijunzhao std::move(__first1), 5420517557Szijunzhao std::move(__last1), 5520517557Szijunzhao std::move(__first2), 5620517557Szijunzhao std::move(__last2), 5720517557Szijunzhao __pred, 5820517557Szijunzhao __proj1, 5920517557Szijunzhao __proj2) 6020517557Szijunzhao .in2 == __last2; 6120517557Szijunzhao } 6220517557Szijunzhao 6320517557Szijunzhao template <input_range _Range1, 6420517557Szijunzhao input_range _Range2, 6520517557Szijunzhao class _Pred = ranges::equal_to, 6620517557Szijunzhao class _Proj1 = identity, 6720517557Szijunzhao class _Proj2 = identity> 6820517557Szijunzhao requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> 6983bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool 70c3747883SXiaoyang Liu operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { 71*d10dc5a0SChristopher Di Bella return __mismatch::__go( 7220517557Szijunzhao ranges::begin(__range1), 7320517557Szijunzhao ranges::end(__range1), 7420517557Szijunzhao ranges::begin(__range2), 7520517557Szijunzhao ranges::end(__range2), 7620517557Szijunzhao __pred, 7720517557Szijunzhao __proj1, 7820517557Szijunzhao __proj2) 7920517557Szijunzhao .in2 == ranges::end(__range2); 8020517557Szijunzhao } 8120517557Szijunzhao }; 8220517557Szijunzhao inline namespace __cpo { 83*d10dc5a0SChristopher Di Bella inline constexpr auto starts_with = __starts_with{}; 8420517557Szijunzhao } // namespace __cpo 8520517557Szijunzhao } // namespace ranges 8620517557Szijunzhao 8720517557Szijunzhao _LIBCPP_END_NAMESPACE_STD 8820517557Szijunzhao 8920517557Szijunzhao #endif // _LIBCPP_STD_VER >= 23 9020517557Szijunzhao 917b462251SLouis Dionne _LIBCPP_POP_MACROS 927b462251SLouis Dionne 9320517557Szijunzhao #endif // _LIBCPP___ALGORITHM_RANGES_STARTS_WITH_H 94