forked from OSchip/llvm-project
[libc++] [test] Fix some GCC 11 errors/warnings in these tests. NFCI.
Differential Revision: https://reviews.llvm.org/D104228
This commit is contained in:
parent
304b9c25d5
commit
389e749c42
|
@ -14,15 +14,16 @@
|
|||
// concept contiguous_iterator;
|
||||
|
||||
#include <iterator>
|
||||
#include <compare>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
static_assert(!std::contiguous_iterator<cpp17_input_iterator<int*> >);
|
||||
static_assert(!std::contiguous_iterator<cpp20_input_iterator<int*> >);
|
||||
static_assert(!std::contiguous_iterator<forward_iterator<int*> >);
|
||||
static_assert(!std::contiguous_iterator<bidirectional_iterator<int*> >);
|
||||
static_assert(!std::contiguous_iterator<random_access_iterator<int*> >);
|
||||
static_assert(std::contiguous_iterator<contiguous_iterator<int*> >);
|
||||
static_assert(!std::contiguous_iterator<cpp17_input_iterator<int*>>);
|
||||
static_assert(!std::contiguous_iterator<cpp20_input_iterator<int*>>);
|
||||
static_assert(!std::contiguous_iterator<forward_iterator<int*>>);
|
||||
static_assert(!std::contiguous_iterator<bidirectional_iterator<int*>>);
|
||||
static_assert(!std::contiguous_iterator<random_access_iterator<int*>>);
|
||||
static_assert(std::contiguous_iterator<contiguous_iterator<int*>>);
|
||||
|
||||
static_assert(std::contiguous_iterator<int*>);
|
||||
static_assert(std::contiguous_iterator<int const*>);
|
||||
|
@ -42,11 +43,7 @@ struct simple_contiguous_iterator {
|
|||
|
||||
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 @@ struct simple_contiguous_iterator {
|
|||
static_assert(std::random_access_iterator<simple_contiguous_iterator>);
|
||||
static_assert(std::contiguous_iterator<simple_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 @@ struct missmatch_value_iter_ref_t {
|
|||
reference operator[](difference_type n) const;
|
||||
};
|
||||
|
||||
static_assert(std::random_access_iterator<missmatch_value_iter_ref_t>);
|
||||
static_assert(!std::contiguous_iterator<missmatch_value_iter_ref_t>);
|
||||
static_assert(std::random_access_iterator<mismatch_value_iter_ref_t>);
|
||||
static_assert(!std::contiguous_iterator<mismatch_value_iter_ref_t>);
|
||||
|
||||
struct wrong_iter_reference_t {
|
||||
typedef std::contiguous_iterator_tag iterator_category;
|
||||
|
@ -118,11 +111,7 @@ struct wrong_iter_reference_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);
|
||||
|
@ -156,11 +145,7 @@ struct no_element_type {
|
|||
|
||||
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 @@ struct to_address_wrong_return_type {
|
|||
|
||||
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 @@ struct template_and_no_element_type {
|
|||
|
||||
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 @@ struct template_and_no_element_type {
|
|||
|
||||
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;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
#include "test_iterators.h"
|
||||
#include "test_macros.h"
|
||||
|
||||
static_assert(!std::random_access_iterator<cpp17_input_iterator<int*> >);
|
||||
static_assert(!std::random_access_iterator<cpp20_input_iterator<int*> >);
|
||||
static_assert(!std::random_access_iterator<forward_iterator<int*> >);
|
||||
static_assert(!std::random_access_iterator<bidirectional_iterator<int*> >);
|
||||
static_assert( std::random_access_iterator<random_access_iterator<int*> >);
|
||||
static_assert( std::random_access_iterator<contiguous_iterator<int*> >);
|
||||
static_assert(!std::random_access_iterator<cpp17_input_iterator<int*>>);
|
||||
static_assert(!std::random_access_iterator<cpp20_input_iterator<int*>>);
|
||||
static_assert(!std::random_access_iterator<forward_iterator<int*>>);
|
||||
static_assert(!std::random_access_iterator<bidirectional_iterator<int*>>);
|
||||
static_assert( std::random_access_iterator<random_access_iterator<int*>>);
|
||||
static_assert( std::random_access_iterator<contiguous_iterator<int*>>);
|
||||
|
||||
static_assert(std::random_access_iterator<int*>);
|
||||
static_assert(std::random_access_iterator<int const*>);
|
||||
|
@ -40,11 +40,7 @@ struct wrong_iterator_category {
|
|||
|
||||
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 @@ struct common_base {
|
|||
|
||||
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<simple_random_access_iterator> {
|
||||
|
||||
struct simple_random_access_iterator : common_base<simple_random_access_iterator> {
|
||||
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<simple_random_access_iterator>);
|
||||
static_assert(std::random_access_iterator<simple_random_access_iterator>);
|
||||
|
||||
struct no_plus_equals
|
||||
: common_base<no_plus_equals> {
|
||||
|
||||
struct no_plus_equals : common_base<no_plus_equals> {
|
||||
/* 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<no_plus_equals>);
|
||||
static_assert(!std::random_access_iterator<no_plus_equals>);
|
||||
|
||||
struct no_plus_difference_type
|
||||
: common_base<no_plus_difference_type> {
|
||||
|
||||
struct no_plus_difference_type : common_base<no_plus_difference_type> {
|
||||
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<no_plus_difference_type>);
|
||||
static_assert(!std::random_access_iterator<no_plus_difference_type>);
|
||||
|
||||
struct difference_type_no_plus
|
||||
: common_base<difference_type_no_plus> {
|
||||
|
||||
struct difference_type_no_plus : common_base<difference_type_no_plus> {
|
||||
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<difference_type_no_plus>);
|
||||
static_assert(!std::random_access_iterator<difference_type_no_plus>);
|
||||
|
||||
struct no_minus_equals
|
||||
: common_base<no_minus_equals> {
|
||||
|
||||
struct no_minus_equals : common_base<no_minus_equals> {
|
||||
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<no_minus_equals>);
|
||||
static_assert(!std::random_access_iterator<no_minus_equals>);
|
||||
|
||||
struct no_minus
|
||||
: common_base<no_minus> {
|
||||
|
||||
struct no_minus : common_base<no_minus> {
|
||||
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<no_minus>);
|
||||
static_assert(!std::random_access_iterator<no_minus>);
|
||||
|
||||
struct not_sized_sentinel
|
||||
: common_base<not_sized_sentinel> {
|
||||
|
||||
struct not_sized_sentinel : common_base<not_sized_sentinel> {
|
||||
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<not_sized_sentinel>);
|
||||
static_assert(!std::random_access_iterator<not_sized_sentinel>);
|
||||
|
||||
struct no_subscript
|
||||
: common_base<no_subscript> {
|
||||
|
||||
struct no_subscript : common_base<no_subscript> {
|
||||
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<no_subscript>);
|
||||
static_assert(!std::random_access_iterator<no_subscript>);
|
||||
|
|
|
@ -36,11 +36,14 @@ struct BeginMember {
|
|||
};
|
||||
|
||||
// Ensure that we can't call with rvalues with borrowing disabled.
|
||||
static_assert( std::is_invocable_v<RangeBeginT, BeginMember &>);
|
||||
static_assert( std::is_invocable_v<RangeBeginT, BeginMember const&>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginMember &&>);
|
||||
static_assert( std::is_invocable_v<RangeBeginT, BeginMember &>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginMember &&>);
|
||||
static_assert( std::is_invocable_v<RangeBeginT, BeginMember const&>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginMember const&&>);
|
||||
static_assert( std::is_invocable_v<RangeCBeginT, BeginMember &>);
|
||||
static_assert(!std::is_invocable_v<RangeCBeginT, BeginMember &&>);
|
||||
static_assert( std::is_invocable_v<RangeCBeginT, BeginMember const&>);
|
||||
static_assert( std::is_invocable_v<RangeCBeginT, BeginMember const&&>);
|
||||
|
||||
constexpr bool testArray() {
|
||||
int a[2];
|
||||
|
@ -61,46 +64,41 @@ constexpr bool testArray() {
|
|||
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<RangeBeginT, BeginMemberReturnsInt const&>);
|
||||
|
||||
struct BeginMemberReturnsVoidPtr {
|
||||
const void *begin() const;
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginMemberReturnsVoidPtr const&>);
|
||||
|
||||
struct Empty { };
|
||||
struct EmptyBeginMember {
|
||||
Empty begin() const;
|
||||
struct iterator {};
|
||||
iterator begin() const;
|
||||
};
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, EmptyBeginMember const&>);
|
||||
|
||||
struct EmptyPtrBeginMember {
|
||||
struct Empty {};
|
||||
Empty x;
|
||||
constexpr const Empty *begin() const { return &x; }
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, EmptyBeginMember const&>);
|
||||
|
||||
struct PtrConvertible {
|
||||
operator int*() const;
|
||||
};
|
||||
struct PtrConvertibleBeginMember {
|
||||
PtrConvertible begin() const;
|
||||
struct iterator { operator int*() const; };
|
||||
iterator begin() const;
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, PtrConvertibleBeginMember const&>);
|
||||
|
||||
struct NonConstBeginMember {
|
||||
int x;
|
||||
constexpr int *begin() { return &x; }
|
||||
};
|
||||
|
||||
static_assert( std::is_invocable_v<RangeBeginT, NonConstBeginMember &>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, NonConstBeginMember const&>);
|
||||
static_assert(!std::is_invocable_v<RangeCBeginT, NonConstBeginMember &>);
|
||||
|
@ -109,7 +107,6 @@ static_assert(!std::is_invocable_v<RangeCBeginT, NonConstBeginMember const&>);
|
|||
struct EnabledBorrowingBeginMember {
|
||||
constexpr int *begin() const { return &globalBuff[0]; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline constexpr bool std::ranges::enable_borrowed_range<EnabledBorrowingBeginMember> = true;
|
||||
|
||||
|
@ -135,11 +132,11 @@ constexpr bool testBeginMember() {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
struct BeginFunction {
|
||||
int x;
|
||||
friend constexpr const int *begin(BeginFunction const& bf) { return &bf.x; }
|
||||
};
|
||||
|
||||
static_assert( std::is_invocable_v<RangeBeginT, BeginFunction const&>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunction &&>);
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunction &>);
|
||||
|
@ -152,12 +149,15 @@ struct BeginFunctionWithDataMember {
|
|||
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 BeginFunctionReturnsEmptyPtr {
|
|||
struct BeginFunctionByValue {
|
||||
friend constexpr int *begin(BeginFunctionByValue) { return &globalBuff[1]; }
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeCBeginT, BeginFunctionByValue>);
|
||||
|
||||
struct BeginFunctionEnabledBorrowing {
|
||||
friend constexpr int *begin(BeginFunctionEnabledBorrowing) { return &globalBuff[2]; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline constexpr bool std::ranges::enable_borrowed_range<BeginFunctionEnabledBorrowing> = true;
|
||||
|
||||
struct BeginFunctionReturnsInt {
|
||||
friend constexpr int begin(BeginFunctionReturnsInt const&);
|
||||
friend int begin(BeginFunctionReturnsInt const&);
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunctionReturnsInt const&>);
|
||||
|
||||
struct BeginFunctionReturnsVoidPtr {
|
||||
friend constexpr void *begin(BeginFunctionReturnsVoidPtr const&);
|
||||
friend void *begin(BeginFunctionReturnsVoidPtr const&);
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunctionReturnsVoidPtr const&>);
|
||||
|
||||
struct BeginFunctionReturnsEmpty {
|
||||
friend constexpr Empty begin(BeginFunctionReturnsEmpty const&);
|
||||
struct Empty {};
|
||||
friend Empty begin(BeginFunctionReturnsEmpty const&);
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunctionReturnsEmpty const&>);
|
||||
|
||||
struct BeginFunctionReturnsPtrConvertible {
|
||||
friend constexpr PtrConvertible begin(BeginFunctionReturnsPtrConvertible const&);
|
||||
struct iterator { operator int*() const; };
|
||||
friend iterator begin(BeginFunctionReturnsPtrConvertible const&);
|
||||
};
|
||||
|
||||
static_assert(!std::is_invocable_v<RangeBeginT, BeginFunctionReturnsPtrConvertible const&>);
|
||||
|
||||
constexpr bool testBeginFunction() {
|
||||
const BeginFunction a{};
|
||||
assert(std::ranges::begin(a) == &a.x);
|
||||
BeginFunction aa{};
|
||||
BeginFunction a{};
|
||||
const BeginFunction aa{};
|
||||
static_assert(!std::invocable<decltype(std::ranges::begin), decltype((a))>);
|
||||
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]);
|
||||
static_assert(!std::invocable<decltype(std::ranges::cbegin), decltype(std::move(c))>);
|
||||
assert(std::ranges::begin(std::move(cc)) == &globalBuff[2]);
|
||||
assert(std::ranges::cbegin(std::move(cc)) == &globalBuff[2]);
|
||||
|
||||
const BeginFunctionReturnsEmptyPtr d{};
|
||||
assert(std::ranges::begin(d) == &d.x);
|
||||
BeginFunctionReturnsEmptyPtr dd{};
|
||||
BeginFunctionReturnsEmptyPtr d{};
|
||||
const BeginFunctionReturnsEmptyPtr dd{};
|
||||
static_assert(!std::invocable<decltype(std::ranges::begin), decltype((d))>);
|
||||
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<decltype(std::ranges::begin), decltype((e))>);
|
||||
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<decltype(std::ranges::begin), decltype((f))>);
|
||||
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<int (&)[10]>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval<int (&)[10]>()));
|
||||
|
||||
template<class T>
|
||||
struct NoThrowMemberBegin {
|
||||
T begin() noexcept;
|
||||
T begin() const noexcept;
|
||||
};
|
||||
ASSERT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberBegin<int*>&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval<NoThrowMemberBegin<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberBegin<ThrowingIterator<int>>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval<NoThrowMemberBegin<ThrowingIterator<int>>&>()));
|
||||
|
||||
template<class T>
|
||||
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<int (&)[10]>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberBegin<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberBegin<ThrowingIterator<int> >&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLBegin<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLBegin<ThrowingIterator<int> >&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval<NoThrowADLBegin<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLBegin<ThrowingIterator<int>>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval<NoThrowADLBegin<ThrowingIterator<int>>&>()));
|
||||
|
||||
|
||||
int main(int, char**) {
|
||||
|
|
|
@ -273,26 +273,31 @@ constexpr bool testEndFunction() {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
ASSERT_NOEXCEPT(std::ranges::end(std::declval<int (&)[10]>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cend(std::declval<int (&)[10]>()));
|
||||
|
||||
template<class T>
|
||||
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<NoThrowMemberEnd<int*>&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cend(std::declval<NoThrowMemberEnd<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval<NoThrowMemberEnd<ThrowingIterator<int>>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval<NoThrowMemberEnd<ThrowingIterator<int>>&>()));
|
||||
|
||||
template<class T>
|
||||
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<int (&)[10]>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberEnd<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowMemberEnd<ThrowingIterator<int> >&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLEnd<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval<NoThrowADLEnd<ThrowingIterator<int> >&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::end(std::declval<NoThrowADLEnd<int*>&>()));
|
||||
ASSERT_NOEXCEPT(std::ranges::cend(std::declval<NoThrowADLEnd<int*>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval<NoThrowADLEnd<ThrowingIterator<int>>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval<NoThrowADLEnd<ThrowingIterator<int>>&>()));
|
||||
|
||||
|
||||
int main(int, char**) {
|
||||
testArray();
|
|
@ -22,13 +22,13 @@ int globalBuff[8];
|
|||
|
||||
template<bool IsNoexcept>
|
||||
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 @@ static_assert(std::ranges::view<View<false>>);
|
|||
|
||||
template<bool IsNoexcept>
|
||||
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<CopyableView<true>>);
|
|||
static_assert(std::ranges::view<CopyableView<false>>);
|
||||
|
||||
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<BorrowableRange> = true;
|
||||
|
||||
|
@ -81,8 +80,6 @@ struct RandomAccessRange {
|
|||
constexpr random_access_iterator<int*> begin() { return random_access_iterator<int*>{globalBuff}; }
|
||||
constexpr sentinel end() { return {}; }
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
inline constexpr bool std::ranges::enable_borrowed_range<RandomAccessRange> = true;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ struct ConditionallyConvertibleBase {
|
|||
|
||||
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;
|
||||
|
|
|
@ -43,20 +43,16 @@ struct InputRange : std::ranges::view_interface<InputRange> {
|
|||
};
|
||||
|
||||
struct NotSizedSentinel {
|
||||
using I = int*;
|
||||
using value_type = std::iter_value_t<I>;
|
||||
using difference_type = std::iter_difference_t<I>;
|
||||
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<NotSizedSentinel>);
|
||||
|
||||
|
@ -127,13 +123,13 @@ struct BoolConvertibleComparison : std::ranges::view_interface<BoolConvertibleCo
|
|||
};
|
||||
|
||||
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};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: gcc-10
|
||||
// XFAIL: gcc-10, gcc-11
|
||||
// GCC's __builtin_strlen isn't constexpr yet
|
||||
// UNSUPPORTED: LIBCXX-DEBUG-FIXME
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
// <tuple>
|
||||
|
||||
|
|
Loading…
Reference in New Issue