Skip to content

Commit 79e8041

Browse files
LWG-3853: basic_const_iterator<volatile int*>::operator-> is ill-formed (#3468)
1 parent a07c68b commit 79e8041

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

stl/inc/xutility

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ public:
18621862
return static_cast<_Reference>(*_Current);
18631863
}
18641864

1865-
_NODISCARD constexpr const value_type* operator->() const
1865+
_NODISCARD constexpr const auto* operator->() const
18661866
noexcept(contiguous_iterator<_Iter> || noexcept(*_Current)) /* strengthened */
18671867
requires is_lvalue_reference_v<iter_reference_t<_Iter>>
18681868
&& same_as<remove_cvref_t<iter_reference_t<_Iter>>, value_type>

tests/std/tests/P2278R4_basic_const_iterator/test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ constexpr void test_one(It iter) {
250250
}
251251
}
252252

253+
void test_lwg3853() { // COMPILE-ONLY
254+
basic_const_iterator<volatile int*> it;
255+
[[maybe_unused]] same_as<const volatile int*> auto ptr = it.operator->();
256+
}
257+
253258
static constexpr int some_ints[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
254259

255260
struct instantiator {

0 commit comments

Comments
 (0)