diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp --- a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp @@ -14,15 +14,16 @@ // concept contiguous_iterator; #include +#include #include "test_iterators.h" -static_assert(!std::contiguous_iterator >); -static_assert(!std::contiguous_iterator >); -static_assert(!std::contiguous_iterator >); -static_assert(!std::contiguous_iterator >); -static_assert(!std::contiguous_iterator >); -static_assert(std::contiguous_iterator >); +static_assert(!std::contiguous_iterator>); +static_assert(!std::contiguous_iterator>); +static_assert(!std::contiguous_iterator>); +static_assert(!std::contiguous_iterator>); +static_assert(!std::contiguous_iterator>); +static_assert(std::contiguous_iterator>); static_assert(std::contiguous_iterator); static_assert(std::contiguous_iterator); @@ -42,11 +43,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -68,23 +65,19 @@ static_assert(std::random_access_iterator); static_assert(std::contiguous_iterator); -struct missmatch_value_iter_ref_t { +struct mismatch_value_iter_ref_t { typedef std::contiguous_iterator_tag iterator_category; typedef short value_type; typedef std::ptrdiff_t difference_type; typedef int* pointer; typedef int& reference; - typedef missmatch_value_iter_ref_t self; + typedef mismatch_value_iter_ref_t self; - missmatch_value_iter_ref_t(); + mismatch_value_iter_ref_t(); reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -103,8 +96,8 @@ reference operator[](difference_type n) const; }; -static_assert(std::random_access_iterator); -static_assert(!std::contiguous_iterator); +static_assert(std::random_access_iterator); +static_assert(!std::contiguous_iterator); struct wrong_iter_reference_t { typedef std::contiguous_iterator_tag iterator_category; @@ -118,11 +111,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -156,11 +145,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -195,11 +180,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -240,11 +221,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self& y); - friend bool operator< (const self&, const self& y); - friend bool operator<=(const self&, const self& y); - friend bool operator> (const self&, const self& y); - friend bool operator>=(const self&, const self& y); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -254,7 +231,7 @@ self& operator+=(difference_type n); self operator+(difference_type n) const; - friend self operator+(difference_type n, self x); + friend self operator+(difference_type, self) { return self{}; } self& operator-=(difference_type n); self operator-(difference_type n) const; diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/random_access_iterator.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/random_access_iterator.compile.pass.cpp --- a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/random_access_iterator.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/random_access_iterator.compile.pass.cpp @@ -18,12 +18,12 @@ #include "test_iterators.h" #include "test_macros.h" -static_assert(!std::random_access_iterator >); -static_assert(!std::random_access_iterator >); -static_assert(!std::random_access_iterator >); -static_assert(!std::random_access_iterator >); -static_assert( std::random_access_iterator >); -static_assert( std::random_access_iterator >); +static_assert(!std::random_access_iterator>); +static_assert(!std::random_access_iterator>); +static_assert(!std::random_access_iterator>); +static_assert(!std::random_access_iterator>); +static_assert( std::random_access_iterator>); +static_assert( std::random_access_iterator>); static_assert(std::random_access_iterator); static_assert(std::random_access_iterator); @@ -40,11 +40,7 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self&); - friend bool operator< (const self&, const self&); - friend bool operator<=(const self&, const self&); - friend bool operator> (const self&, const self&); - friend bool operator>=(const self&, const self&); + auto operator<=>(const self&) const = default; self& operator++(); self operator++(int); @@ -76,143 +72,113 @@ reference operator*() const; pointer operator->() const; - friend bool operator==(const self&, const self&); - friend bool operator< (const self&, const self&); - friend bool operator<=(const self&, const self&); - friend bool operator> (const self&, const self&); - friend bool operator>=(const self&, const self&); - self& operator++(); self operator++(int); - self& operator--(); self operator--(int); + auto operator<=>(const common_base&) const = default; }; -struct simple_random_access_iterator - : common_base { - +struct simple_random_access_iterator : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); self operator-(difference_type n) const; difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert(std::bidirectional_iterator); static_assert(std::random_access_iterator); -struct no_plus_equals - : common_base { - +struct no_plus_equals : common_base { /* self& operator+=(difference_type n); */ self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); self operator-(difference_type n) const; difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct no_plus_difference_type - : common_base { - +struct no_plus_difference_type : common_base { self& operator+=(difference_type n); /* self operator+(difference_type n) const; */ friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); self operator-(difference_type n) const; difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct difference_type_no_plus - : common_base { - +struct difference_type_no_plus : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; /* friend self operator+(difference_type n, self x); */ - self& operator-=(difference_type n); self operator-(difference_type n) const; difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct no_minus_equals - : common_base { - +struct no_minus_equals : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - /* self& operator-=(difference_type n); */ self operator-(difference_type n) const; difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct no_minus - : common_base { - +struct no_minus : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); /* self operator-(difference_type n) const; */ difference_type operator-(const self&) const; - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct not_sized_sentinel - : common_base { - +struct not_sized_sentinel : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); self operator-(difference_type n) const; /* difference_type operator-(const self&) const; */ - reference operator[](difference_type n) const; + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); -struct no_subscript - : common_base { - +struct no_subscript : common_base { self& operator+=(difference_type n); self operator+(difference_type n) const; friend self operator+(difference_type n, self x); - self& operator-=(difference_type n); self operator-(difference_type n) const; difference_type operator-(const self&) const; - /* reference operator[](difference_type n) const; */ + auto operator<=>(const self&) const = default; }; static_assert( std::bidirectional_iterator); static_assert(!std::random_access_iterator); diff --git a/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp b/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp --- a/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp @@ -36,11 +36,14 @@ }; // Ensure that we can't call with rvalues with borrowing disabled. -static_assert( std::is_invocable_v); -static_assert( std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); +static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); +static_assert( std::is_invocable_v); constexpr bool testArray() { int a[2]; @@ -61,46 +64,41 @@ struct BeginMemberFunction { int x; constexpr const int *begin() const { return &x; } - friend constexpr int *begin(BeginMemberFunction const& bf); + friend int *begin(BeginMemberFunction const&); }; struct BeginMemberReturnsInt { int begin() const; }; - static_assert(!std::is_invocable_v); struct BeginMemberReturnsVoidPtr { const void *begin() const; }; - static_assert(!std::is_invocable_v); -struct Empty { }; struct EmptyBeginMember { - Empty begin() const; + struct iterator {}; + iterator begin() const; }; +static_assert(!std::is_invocable_v); + struct EmptyPtrBeginMember { + struct Empty {}; Empty x; constexpr const Empty *begin() const { return &x; } }; -static_assert(!std::is_invocable_v); - -struct PtrConvertible { - operator int*() const; -}; struct PtrConvertibleBeginMember { - PtrConvertible begin() const; + struct iterator { operator int*() const; }; + iterator begin() const; }; - static_assert(!std::is_invocable_v); struct NonConstBeginMember { int x; constexpr int *begin() { return &x; } }; - static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); @@ -109,7 +107,6 @@ struct EnabledBorrowingBeginMember { constexpr int *begin() const { return &globalBuff[0]; } }; - template<> inline constexpr bool std::ranges::enable_borrowed_range = true; @@ -135,11 +132,11 @@ return true; } + struct BeginFunction { int x; friend constexpr const int *begin(BeginFunction const& bf) { return &bf.x; } }; - static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); @@ -152,12 +149,15 @@ friend constexpr const int *begin(BeginFunctionWithDataMember const& bf) { return &bf.x; } }; -struct BeginFunctionWithPrivateBeginMember : private BeginMember { +struct BeginFunctionWithPrivateBeginMember { int y; friend constexpr const int *begin(BeginFunctionWithPrivateBeginMember const& bf) { return &bf.y; } +private: + const int *begin() const; }; struct BeginFunctionReturnsEmptyPtr { + struct Empty {}; Empty x; friend constexpr const Empty *begin(BeginFunctionReturnsEmptyPtr const& bf) { return &bf.x; } }; @@ -165,87 +165,104 @@ struct BeginFunctionByValue { friend constexpr int *begin(BeginFunctionByValue) { return &globalBuff[1]; } }; - static_assert(!std::is_invocable_v); struct BeginFunctionEnabledBorrowing { friend constexpr int *begin(BeginFunctionEnabledBorrowing) { return &globalBuff[2]; } }; - template<> inline constexpr bool std::ranges::enable_borrowed_range = true; struct BeginFunctionReturnsInt { - friend constexpr int begin(BeginFunctionReturnsInt const&); + friend int begin(BeginFunctionReturnsInt const&); }; - static_assert(!std::is_invocable_v); struct BeginFunctionReturnsVoidPtr { - friend constexpr void *begin(BeginFunctionReturnsVoidPtr const&); + friend void *begin(BeginFunctionReturnsVoidPtr const&); }; - static_assert(!std::is_invocable_v); struct BeginFunctionReturnsEmpty { - friend constexpr Empty begin(BeginFunctionReturnsEmpty const&); + struct Empty {}; + friend Empty begin(BeginFunctionReturnsEmpty const&); }; - static_assert(!std::is_invocable_v); struct BeginFunctionReturnsPtrConvertible { - friend constexpr PtrConvertible begin(BeginFunctionReturnsPtrConvertible const&); + struct iterator { operator int*() const; }; + friend iterator begin(BeginFunctionReturnsPtrConvertible const&); }; - static_assert(!std::is_invocable_v); constexpr bool testBeginFunction() { - const BeginFunction a{}; - assert(std::ranges::begin(a) == &a.x); - BeginFunction aa{}; + BeginFunction a{}; + const BeginFunction aa{}; + static_assert(!std::invocable); + assert(std::ranges::begin(aa) == &aa.x); + assert(std::ranges::cbegin(a) == &a.x); assert(std::ranges::cbegin(aa) == &aa.x); - BeginFunctionByValue b; + BeginFunctionByValue b{}; + const BeginFunctionByValue bb{}; assert(std::ranges::begin(b) == &globalBuff[1]); + assert(std::ranges::begin(bb) == &globalBuff[1]); assert(std::ranges::cbegin(b) == &globalBuff[1]); + assert(std::ranges::cbegin(bb) == &globalBuff[1]); - BeginFunctionEnabledBorrowing c; + BeginFunctionEnabledBorrowing c{}; + const BeginFunctionEnabledBorrowing cc{}; assert(std::ranges::begin(std::move(c)) == &globalBuff[2]); - - const BeginFunctionReturnsEmptyPtr d{}; - assert(std::ranges::begin(d) == &d.x); - BeginFunctionReturnsEmptyPtr dd{}; + static_assert(!std::invocable); + assert(std::ranges::begin(std::move(cc)) == &globalBuff[2]); + assert(std::ranges::cbegin(std::move(cc)) == &globalBuff[2]); + + BeginFunctionReturnsEmptyPtr d{}; + const BeginFunctionReturnsEmptyPtr dd{}; + static_assert(!std::invocable); + assert(std::ranges::begin(dd) == &dd.x); + assert(std::ranges::cbegin(d) == &d.x); assert(std::ranges::cbegin(dd) == &dd.x); - const BeginFunctionWithDataMember e{}; - assert(std::ranges::begin(e) == &e.x); - BeginFunctionWithDataMember ee{}; + BeginFunctionWithDataMember e{}; + const BeginFunctionWithDataMember ee{}; + static_assert(!std::invocable); + assert(std::ranges::begin(ee) == &ee.x); + assert(std::ranges::cbegin(e) == &e.x); assert(std::ranges::cbegin(ee) == &ee.x); - const BeginFunctionWithPrivateBeginMember f{}; - assert(std::ranges::begin(f) == &f.y); - BeginFunctionWithPrivateBeginMember ff{}; + BeginFunctionWithPrivateBeginMember f{}; + const BeginFunctionWithPrivateBeginMember ff{}; + static_assert(!std::invocable); + assert(std::ranges::begin(ff) == &ff.y); + assert(std::ranges::cbegin(f) == &f.y); assert(std::ranges::cbegin(ff) == &ff.y); return true; } + +ASSERT_NOEXCEPT(std::ranges::begin(std::declval())); +ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval())); + template struct NoThrowMemberBegin { - T begin() noexcept; T begin() const noexcept; }; +ASSERT_NOEXCEPT(std::ranges::begin(std::declval&>())); +ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval>&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval>&>())); template struct NoThrowADLBegin { - friend T begin(NoThrowADLBegin&) noexcept; - friend T begin(NoThrowADLBegin const&) noexcept; + friend T begin(NoThrowADLBegin&) noexcept { return T{}; } + friend T begin(NoThrowADLBegin const&) noexcept { return T{}; } }; -ASSERT_NOEXCEPT(std::ranges::begin(std::declval())); -ASSERT_NOEXCEPT(std::ranges::begin(std::declval&>())); -ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval >&>())); ASSERT_NOEXCEPT(std::ranges::begin(std::declval&>())); -ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval >&>())); +ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval>&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval>&>())); int main(int, char**) { diff --git a/libcxx/test/std/ranges/range.access/range.access.end/end.cpp b/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp rename from libcxx/test/std/ranges/range.access/range.access.end/end.cpp rename to libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp --- a/libcxx/test/std/ranges/range.access/range.access.end/end.cpp +++ b/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp @@ -273,26 +273,31 @@ return true; } + +ASSERT_NOEXCEPT(std::ranges::end(std::declval())); +ASSERT_NOEXCEPT(std::ranges::cend(std::declval())); + template struct NoThrowMemberEnd { - T begin() noexcept; - T begin() const noexcept; - T end() noexcept; + T begin() const; T end() const noexcept; }; +ASSERT_NOEXCEPT(std::ranges::end(std::declval&>())); +ASSERT_NOEXCEPT(std::ranges::cend(std::declval&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval>&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval>&>())); template struct NoThrowADLEnd { - friend T begin(NoThrowADLEnd&) noexcept; - friend T begin(NoThrowADLEnd const&) noexcept; - friend T end(NoThrowADLEnd&) noexcept; - friend T end(NoThrowADLEnd const&) noexcept; + T begin() const; + friend T end(NoThrowADLEnd&) noexcept { return T{}; } + friend T end(NoThrowADLEnd const&) noexcept { return T{}; } }; -ASSERT_NOEXCEPT(std::ranges::begin(std::declval())); -ASSERT_NOEXCEPT(std::ranges::begin(std::declval&>())); -ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval >&>())); -ASSERT_NOEXCEPT(std::ranges::begin(std::declval&>())); -ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval >&>())); +ASSERT_NOEXCEPT(std::ranges::end(std::declval&>())); +ASSERT_NOEXCEPT(std::ranges::cend(std::declval&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval>&>())); +ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval>&>())); + int main(int, char**) { testArray(); diff --git a/libcxx/test/std/ranges/range.adaptors/range.all.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.all.pass.cpp --- a/libcxx/test/std/ranges/range.adaptors/range.all.pass.cpp +++ b/libcxx/test/std/ranges/range.adaptors/range.all.pass.cpp @@ -22,13 +22,13 @@ template struct View : std::ranges::view_base { - int start = 0; - constexpr explicit View(int start) : start(start) {} - View() noexcept(IsNoexcept) = default; + int start_ = 0; + explicit View() noexcept(IsNoexcept) = default; + constexpr explicit View(int start) : start_(start) {} View(View&&) noexcept(IsNoexcept) = default; View& operator=(View&&) noexcept(IsNoexcept) = default; - constexpr friend int* begin(View& view) { return globalBuff + view.start; } - constexpr friend int* begin(View const& view) { return globalBuff + view.start; } + constexpr friend int* begin(View& view) { return globalBuff + view.start_; } + constexpr friend int* begin(View const& view) { return globalBuff + view.start_; } constexpr friend int* end(View&) { return globalBuff + 8; } constexpr friend int* end(View const&) { return globalBuff + 8; } }; @@ -37,13 +37,13 @@ template struct CopyableView : std::ranges::view_base { - int start = 0; - CopyableView() noexcept(IsNoexcept) = default; + int start_ = 0; + explicit CopyableView() noexcept(IsNoexcept) = default; CopyableView(CopyableView const&) noexcept(IsNoexcept) = default; CopyableView& operator=(CopyableView const&) noexcept(IsNoexcept) = default; - constexpr explicit CopyableView(int start) noexcept : start(start) {} - constexpr friend int* begin(CopyableView& view) { return globalBuff + view.start; } - constexpr friend int* begin(CopyableView const& view) { return globalBuff + view.start; } + constexpr explicit CopyableView(int start) noexcept : start_(start) {} + constexpr friend int* begin(CopyableView& view) { return globalBuff + view.start_; } + constexpr friend int* begin(CopyableView const& view) { return globalBuff + view.start_; } constexpr friend int* end(CopyableView&) { return globalBuff + 8; } constexpr friend int* end(CopyableView const&) { return globalBuff + 8; } }; @@ -51,23 +51,22 @@ static_assert(std::ranges::view>); struct Range { - int start = 0; - constexpr explicit Range(int start) noexcept : start(start) {} - constexpr friend int* begin(Range const& range) { return globalBuff + range.start; } + int start_; + constexpr explicit Range(int start) noexcept : start_(start) {} + constexpr friend int* begin(Range const& range) { return globalBuff + range.start_; } + constexpr friend int* begin(Range& range) { return globalBuff + range.start_; } constexpr friend int* end(Range const&) { return globalBuff + 8; } - constexpr friend int* begin(Range& range) { return globalBuff + range.start; } constexpr friend int* end(Range&) { return globalBuff + 8; } }; struct BorrowableRange { - int start = 0; - constexpr explicit BorrowableRange(int start) noexcept : start(start) {} - constexpr friend int* begin(BorrowableRange const& range) { return globalBuff + range.start; } + int start_; + constexpr explicit BorrowableRange(int start) noexcept : start_(start) {} + constexpr friend int* begin(BorrowableRange const& range) { return globalBuff + range.start_; } + constexpr friend int* begin(BorrowableRange& range) { return globalBuff + range.start_; } constexpr friend int* end(BorrowableRange const&) { return globalBuff + 8; } - constexpr friend int* begin(BorrowableRange& range) { return globalBuff + range.start; } constexpr friend int* end(BorrowableRange&) { return globalBuff + 8; } }; - template<> inline constexpr bool std::ranges::enable_borrowed_range = true; @@ -81,8 +80,6 @@ constexpr random_access_iterator begin() { return random_access_iterator{globalBuff}; } constexpr sentinel end() { return {}; } }; - - template<> inline constexpr bool std::ranges::enable_borrowed_range = true; diff --git a/libcxx/test/std/ranges/range.utility/range.subrange/subrange_test_types.h b/libcxx/test/std/ranges/range.utility/range.subrange/subrange_test_types.h --- a/libcxx/test/std/ranges/range.utility/range.subrange/subrange_test_types.h +++ b/libcxx/test/std/ranges/range.utility/range.subrange/subrange_test_types.h @@ -135,7 +135,7 @@ constexpr int *base() const { return base_; } - friend bool operator==(const self&, const self&); + friend bool operator==(const self&, const self&) = default; reference operator*() const; pointer operator->() const; diff --git a/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp b/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp --- a/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp +++ b/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp @@ -43,20 +43,16 @@ }; struct NotSizedSentinel { - using I = int*; - using value_type = std::iter_value_t; - using difference_type = std::iter_difference_t; + using value_type = int; + using difference_type = std::ptrdiff_t; using iterator_concept = std::forward_iterator_tag; - NotSizedSentinel() = default; - explicit constexpr NotSizedSentinel(I); - - constexpr int &operator*() const { return *value; }; + explicit NotSizedSentinel() = default; + explicit NotSizedSentinel(int*); + int& operator*() const; NotSizedSentinel& operator++(); NotSizedSentinel operator++(int); bool operator==(NotSizedSentinel const&) const; - - int *value; }; static_assert(std::forward_iterator); @@ -127,13 +123,13 @@ }; struct SentinelType { - int *base; + int *base_; SentinelType() = default; - explicit constexpr SentinelType(int *base) : base(base) {} - friend constexpr ResultType operator==(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() == sent.base}; } - friend constexpr ResultType operator==(SentinelType const& sent, ForwardIter const& iter) noexcept { return {iter.base() == sent.base}; } - friend constexpr ResultType operator!=(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() != sent.base}; } - friend constexpr ResultType operator!=(SentinelType const& sent, ForwardIter const& iter) noexcept { return {iter.base() != sent.base}; } + explicit constexpr SentinelType(int *base) : base_(base) {} + friend constexpr ResultType operator==(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() == sent.base_}; } + friend constexpr ResultType operator==(SentinelType const& sent, ForwardIter const& iter) noexcept { return {iter.base() == sent.base_}; } + friend constexpr ResultType operator!=(ForwardIter const& iter, SentinelType const& sent) noexcept { return {iter.base() != sent.base_}; } + friend constexpr ResultType operator!=(SentinelType const& sent, ForwardIter const& iter) noexcept { return {iter.base() != sent.base_}; } }; int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7}; diff --git a/libcxx/test/std/strings/string.view/string.view.ops/copy.pass.cpp b/libcxx/test/std/strings/string.view/string.view.ops/copy.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.ops/copy.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.ops/copy.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: gcc-10 +// XFAIL: gcc-10, gcc-11 // GCC's __builtin_strlen isn't constexpr yet // UNSUPPORTED: LIBCXX-DEBUG-FIXME diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/deduct.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/deduct.pass.cpp --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/deduct.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/deduct.pass.cpp @@ -13,7 +13,7 @@ // GCC's implementation of class template deduction is still immature and runs // into issues with libc++. However GCC accepts this code when compiling // against libstdc++. -// XFAIL: gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10 +// XFAIL: gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10, gcc-11 //