Skip to content

Commit

Permalink
[libcxx][test] {move,reverse}_iterator cannot be instantiated for a t…
Browse files Browse the repository at this point in the history
…ype 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
  • Loading branch information
CaseyCarter committed Jan 24, 2022
1 parent e494278 commit cfe1798
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ToIter {
typedef char *pointer;
typedef char &reference;
typedef char value_type;
typedef value_type difference_type;
typedef signed char difference_type;

explicit TEST_CONSTEXPR_CXX17 ToIter() : m_value(0) {}
TEST_CONSTEXPR_CXX17 ToIter(const ToIter &src) : m_value(src.m_value) {}
Expand All @@ -57,6 +57,8 @@ struct ToIter {
return *this;
}
char *m_value;

reference operator*() const;
};

TEST_CONSTEXPR_CXX17 bool test_conv_assign()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct Iter {

constexpr Iter(double value): m_value(value) {}
double m_value;

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

reference operator*() const;
private:
friend constexpr bool operator==(const ConstIter& l, const ConstIter& r) = default;
friend constexpr std::partial_ordering operator<=>(const ConstIter& l, const ConstIter& r) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct ToIter {
return *this;
}
char *m_value;

reference operator*() const;
};

TEST_CONSTEXPR_CXX17 bool tests() {
Expand Down

0 comments on commit cfe1798

Please sign in to comment.