1fdd089b5SZijunZhaoCCK //===----------------------------------------------------------------------===// 2fdd089b5SZijunZhaoCCK // 3fdd089b5SZijunZhaoCCK // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4fdd089b5SZijunZhaoCCK // See https://llvm.org/LICENSE.txt for license information. 5fdd089b5SZijunZhaoCCK // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6fdd089b5SZijunZhaoCCK // 7fdd089b5SZijunZhaoCCK //===----------------------------------------------------------------------===// 8fdd089b5SZijunZhaoCCK 9fdd089b5SZijunZhaoCCK #ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H 10fdd089b5SZijunZhaoCCK #define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H 11fdd089b5SZijunZhaoCCK 12fdd089b5SZijunZhaoCCK #include <__algorithm/ranges_find.h> 13fdd089b5SZijunZhaoCCK #include <__config> 14fdd089b5SZijunZhaoCCK #include <__functional/identity.h> 15fdd089b5SZijunZhaoCCK #include <__functional/ranges_operations.h> 16fdd089b5SZijunZhaoCCK #include <__functional/reference_wrapper.h> 17fdd089b5SZijunZhaoCCK #include <__iterator/concepts.h> 18fdd089b5SZijunZhaoCCK #include <__iterator/indirectly_comparable.h> 19fdd089b5SZijunZhaoCCK #include <__iterator/projected.h> 20fdd089b5SZijunZhaoCCK #include <__ranges/access.h> 21fdd089b5SZijunZhaoCCK #include <__ranges/concepts.h> 22fdd089b5SZijunZhaoCCK #include <__utility/move.h> 23fdd089b5SZijunZhaoCCK 24fdd089b5SZijunZhaoCCK #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 25fdd089b5SZijunZhaoCCK # pragma GCC system_header 26fdd089b5SZijunZhaoCCK #endif 27fdd089b5SZijunZhaoCCK 287b462251SLouis Dionne _LIBCPP_PUSH_MACROS 297b462251SLouis Dionne #include <__undef_macros> 307b462251SLouis Dionne 31fdd089b5SZijunZhaoCCK #if _LIBCPP_STD_VER >= 23 32fdd089b5SZijunZhaoCCK 33fdd089b5SZijunZhaoCCK _LIBCPP_BEGIN_NAMESPACE_STD 34fdd089b5SZijunZhaoCCK 35fdd089b5SZijunZhaoCCK namespace ranges { 36*d10dc5a0SChristopher Di Bella struct __contains { 37fdd089b5SZijunZhaoCCK template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> 38fdd089b5SZijunZhaoCCK requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> 3983bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static 40fdd089b5SZijunZhaoCCK operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { 41fdd089b5SZijunZhaoCCK return ranges::find(std::move(__first), __last, __value, std::ref(__proj)) != __last; 42fdd089b5SZijunZhaoCCK } 43fdd089b5SZijunZhaoCCK 44fdd089b5SZijunZhaoCCK template <input_range _Range, class _Type, class _Proj = identity> 45fdd089b5SZijunZhaoCCK requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> 4683bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static 47fdd089b5SZijunZhaoCCK operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { 48fdd089b5SZijunZhaoCCK return ranges::find(ranges::begin(__range), ranges::end(__range), __value, std::ref(__proj)) != 49fdd089b5SZijunZhaoCCK ranges::end(__range); 50fdd089b5SZijunZhaoCCK } 51fdd089b5SZijunZhaoCCK }; 52fdd089b5SZijunZhaoCCK 53fdd089b5SZijunZhaoCCK inline namespace __cpo { 54*d10dc5a0SChristopher Di Bella inline constexpr auto contains = __contains{}; 55fdd089b5SZijunZhaoCCK } // namespace __cpo 56fdd089b5SZijunZhaoCCK } // namespace ranges 57fdd089b5SZijunZhaoCCK 58fdd089b5SZijunZhaoCCK _LIBCPP_END_NAMESPACE_STD 59fdd089b5SZijunZhaoCCK 60fdd089b5SZijunZhaoCCK #endif // _LIBCPP_STD_VER >= 23 61fdd089b5SZijunZhaoCCK 627b462251SLouis Dionne _LIBCPP_POP_MACROS 637b462251SLouis Dionne 64fdd089b5SZijunZhaoCCK #endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H 65