Skip to content

Commit

Permalink
LWG-3853: basic_const_iterator<volatile int*>::operator-> is ill-fo…
Browse files Browse the repository at this point in the history
…rmed (#3468)
  • Loading branch information
JMazurkiewicz authored Feb 16, 2023
1 parent a07c68b commit 79e8041
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ public:
return static_cast<_Reference>(*_Current);
}

_NODISCARD constexpr const value_type* operator->() const
_NODISCARD constexpr const auto* operator->() const
noexcept(contiguous_iterator<_Iter> || noexcept(*_Current)) /* strengthened */
requires is_lvalue_reference_v<iter_reference_t<_Iter>>
&& same_as<remove_cvref_t<iter_reference_t<_Iter>>, value_type>
Expand Down
5 changes: 5 additions & 0 deletions tests/std/tests/P2278R4_basic_const_iterator/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ constexpr void test_one(It iter) {
}
}

void test_lwg3853() { // COMPILE-ONLY
basic_const_iterator<volatile int*> it;
[[maybe_unused]] same_as<const volatile int*> auto ptr = it.operator->();
}

static constexpr int some_ints[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

struct instantiator {
Expand Down

0 comments on commit 79e8041

Please sign in to comment.