1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef _LIBCPP___RANGES_ALL_H 10 #define _LIBCPP___RANGES_ALL_H 11 12 #include <__config> 13 #include <__iterator/concepts.h> 14 #include <__iterator/iterator_traits.h> 15 #include <__ranges/access.h> 16 #include <__ranges/concepts.h> 17 #include <__ranges/owning_view.h> 18 #include <__ranges/range_adaptor.h> 19 #include <__ranges/ref_view.h> 20 #include <__utility/auto_cast.h> 21 #include <__utility/declval.h> 22 #include <__utility/forward.h> 23 #include <type_traits> 24 25 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 26 #pragma GCC system_header 27 #endif 28 29 _LIBCPP_BEGIN_NAMESPACE_STD 30 31 #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) 32 33 namespace ranges::views { 34 35 namespace __all { 36 struct __fn : __range_adaptor_closure<__fn> { 37 template<class _Tp> 38 requires ranges::view<decay_t<_Tp>> 39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI 40 constexpr auto operator()(_Tp&& __t) const 41 noexcept(noexcept(_LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)))) 42 { 43 return _LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)); 44 } 45 46 template<class _Tp> 47 requires (!ranges::view<decay_t<_Tp>>) && 48 requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } 49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI 50 constexpr auto operator()(_Tp&& __t) const 51 noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)})) 52 { 53 return ranges::ref_view{_VSTD::forward<_Tp>(__t)}; 54 } 55 56 template<class _Tp> 57 requires (!ranges::view<decay_t<_Tp>> && 58 !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } && 59 requires (_Tp&& __t) { ranges::owning_view{_VSTD::forward<_Tp>(__t)}; }) 60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI 61 constexpr auto operator()(_Tp&& __t) const 62 noexcept(noexcept(ranges::owning_view{_VSTD::forward<_Tp>(__t)})) 63 { 64 return ranges::owning_view{_VSTD::forward<_Tp>(__t)}; 65 } 66 }; 67 } // namespace __all 68 69 inline namespace __cpo { 70 inline constexpr auto all = __all::__fn{}; 71 } // namespace __cpo 72 73 template<ranges::viewable_range _Range> 74 using all_t = decltype(views::all(declval<_Range>())); 75 76 } // namespace ranges::views 77 78 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) 79 80 _LIBCPP_END_NAMESPACE_STD 81 82 #endif // _LIBCPP___RANGES_ALL_H 83