diff --git a/stl/inc/xutility b/stl/inc/xutility index 077097f2f3..c53c060d24 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -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> && same_as>, value_type> diff --git a/tests/std/tests/P2278R4_basic_const_iterator/test.cpp b/tests/std/tests/P2278R4_basic_const_iterator/test.cpp index 660c201c58..2f8de04de8 100644 --- a/tests/std/tests/P2278R4_basic_const_iterator/test.cpp +++ b/tests/std/tests/P2278R4_basic_const_iterator/test.cpp @@ -250,6 +250,11 @@ constexpr void test_one(It iter) { } } +void test_lwg3853() { // COMPILE-ONLY + basic_const_iterator it; + [[maybe_unused]] same_as auto ptr = it.operator->(); +} + static constexpr int some_ints[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; struct instantiator {