[libcxx][test] {move,reverse}_iterator cannot be instantiated for a type with no `operator*`

Since their nested reference types are defined in terms of `iter_reference_t<T>`, which examines `decltype(*declval<T>())`.

Differential Revision: https://reviews.llvm.org/D117371
This commit is contained in:
Casey Carter 2021-12-29 14:30:52 -08:00
parent e494278cee
commit cfe17986c9
3 changed files with 9 additions and 1 deletions

View File

@ -42,7 +42,7 @@ struct ToIter {
typedef char *pointer; typedef char *pointer;
typedef char &reference; typedef char &reference;
typedef char value_type; typedef char value_type;
typedef value_type difference_type; typedef signed char difference_type;
explicit TEST_CONSTEXPR_CXX17 ToIter() : m_value(0) {} explicit TEST_CONSTEXPR_CXX17 ToIter() : m_value(0) {}
TEST_CONSTEXPR_CXX17 ToIter(const ToIter &src) : m_value(src.m_value) {} TEST_CONSTEXPR_CXX17 ToIter(const ToIter &src) : m_value(src.m_value) {}
@ -57,6 +57,8 @@ struct ToIter {
return *this; return *this;
} }
char *m_value; char *m_value;
reference operator*() const;
}; };
TEST_CONSTEXPR_CXX17 bool test_conv_assign() TEST_CONSTEXPR_CXX17 bool test_conv_assign()

View File

@ -42,6 +42,8 @@ struct Iter {
constexpr Iter(double value): m_value(value) {} constexpr Iter(double value): m_value(value) {}
double m_value; double m_value;
reference operator*() const;
private: private:
friend constexpr bool operator==(const Iter& l, const Iter& r) = default; friend constexpr bool operator==(const Iter& l, const Iter& r) = default;
friend constexpr std::partial_ordering operator<=>(const Iter& l, const Iter& r) = default; friend constexpr std::partial_ordering operator<=>(const Iter& l, const Iter& r) = default;
@ -57,6 +59,8 @@ struct ConstIter {
constexpr ConstIter(double value): m_value(value) {} constexpr ConstIter(double value): m_value(value) {}
constexpr ConstIter(Iter it): m_value(it.m_value) {} constexpr ConstIter(Iter it): m_value(it.m_value) {}
double m_value; double m_value;
reference operator*() const;
private: private:
friend constexpr bool operator==(const ConstIter& l, const ConstIter& r) = default; friend constexpr bool operator==(const ConstIter& l, const ConstIter& r) = default;
friend constexpr std::partial_ordering operator<=>(const ConstIter& l, const ConstIter& r) = default; friend constexpr std::partial_ordering operator<=>(const ConstIter& l, const ConstIter& r) = default;

View File

@ -51,6 +51,8 @@ struct ToIter {
return *this; return *this;
} }
char *m_value; char *m_value;
reference operator*() const;
}; };
TEST_CONSTEXPR_CXX17 bool tests() { TEST_CONSTEXPR_CXX17 bool tests() {