#ifdef __cpp_lib_concepts
// Define this here, included by all the headers that need to define it.
+#if __cplusplus > 202002L
+#define __cpp_lib_ranges 202202L
+#else
#define __cpp_lib_ranges 202110L
+#endif
namespace ranges
{
};
} // namespace views::__adaptor
+#if __cplusplus > 202002L
+ template<typename _Derived>
+ requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+ class range_adaptor_closure
+ : public views::__adaptor::_RangeAdaptorClosure
+ { };
+#endif
+
template<range _Range> requires is_object_v<_Range>
class ref_view : public view_interface<ref_view<_Range>>
{
#define __cpp_lib_interpolate 201902L
#if __cpp_lib_concepts
# define __cpp_lib_move_iterator_concept 202207L
+#if __cplusplus <= 202002L // N.B. updated value in C++23
# define __cpp_lib_ranges 202110L
#endif
+#endif
#define __cpp_lib_shift 201806L
#if _GLIBCXX_HOSTED
#define __cpp_lib_reference_from_temporary 202202L
#define __cpp_lib_to_underlying 202102L
#define __cpp_lib_unreachable 202202L
+#define __cpp_lib_ranges 202202L
#define __cpp_lib_ranges_zip 202110L
#define __cpp_lib_ranges_chunk 202202L
#define __cpp_lib_ranges_slide 202202L
--- /dev/null
+// { dg-options "-std=gnu++23" }
+// { dg-do run { target c++23 } }
+
+#include <ranges>
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+namespace ranges = std::ranges;
+namespace views = std::views;
+
+struct _Negate : ranges::range_adaptor_closure<_Negate>
+{
+ template<ranges::viewable_range _Range>
+ constexpr auto
+ operator()(_Range&& __r) const
+ requires requires { views::transform(std::declval<_Range>(), std::negate{}); }
+ { return views::transform(std::forward<_Range>(__r), std::negate{}); }
+};
+
+constexpr _Negate negate;
+
+constexpr bool
+test01()
+{
+ int x[] = {1, 2, 3};
+ VERIFY( ranges::equal(x | negate, (int[]){-1, -2, -3}) );
+ VERIFY( ranges::equal(x | negate | negate, x) );
+ VERIFY( ranges::equal(x | (negate | negate), x) );
+ VERIFY( ranges::equal(x | views::reverse | negate, x | negate | views::reverse) );
+ VERIFY( ranges::equal(x | (views::reverse | negate), x | (negate | views::reverse)) );
+#if 0
+ // These asserts currently fail for the same reason as the disabled asserts
+ // in std/ranges/adaptors/all.cc.
+ static_assert( sizeof(negate | views::reverse | views::join) == 1 );
+ static_assert( sizeof(views::reverse | negate | views::join) == 1 );
+ static_assert( sizeof(views::reverse | views::join | negate) == 1 );
+#endif
+
+ return true;
+}
+
+int
+main()
+{
+ static_assert(test01());
+}