Skip to content

Commit

Permalink
Implement LWG-3618 Unnecessary iter_move for `transform_view::itera…
Browse files Browse the repository at this point in the history
…tor` (#2566)

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
fsb4000 and StephanTLavavej authored Feb 18, 2022
1 parent 7671576 commit 05ac0a5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
12 changes: 2 additions & 10 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ namespace ranges {
_Parent_t* _Parent{};

#if _ITERATOR_DEBUG_LEVEL != 0
constexpr void _Check_dereference() const {
constexpr void _Check_dereference() const noexcept {
_STL_VERIFY(_Parent != nullptr, "cannot dereference value-initialized transform_view iterator");
_STL_VERIFY(_Current != _RANGES end(_Parent->_Range), "cannot dereference end transform_view iterator");
}
Expand Down Expand Up @@ -2002,7 +2002,7 @@ namespace ranges {
}

_NODISCARD constexpr decltype(auto) operator*() const
_NOEXCEPT_IDL0(noexcept(_STD invoke(*_Parent->_Fun, *_Current))) /* strengthened */ {
noexcept(noexcept(_STD invoke(*_Parent->_Fun, *_Current))) {
#if _ITERATOR_DEBUG_LEVEL != 0
_Check_dereference();
_STL_VERIFY(
Expand Down Expand Up @@ -2183,14 +2183,6 @@ namespace ranges {
#endif // _ITERATOR_DEBUG_LEVEL != 0
return _Left._Current - _Right._Current;
}

_NODISCARD friend constexpr decltype(auto) iter_move(const _Iterator& _It) noexcept(noexcept(*_It)) {
if constexpr (is_lvalue_reference_v<decltype(*_It)>) {
return _STD move(*_It);
} else {
return *_It;
}
}
};

template <bool _Const>
Expand Down
2 changes: 0 additions & 2 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.con

# non-portable test of strengthened noexcept
std/ranges/range.adaptors/range.drop/ctor.default.pass.cpp FAIL
std/ranges/range.adaptors/range.transform/iterator/deref.pass.cpp FAIL
std/ranges/range.adaptors/range.transform/iterator/iter_move.pass.cpp FAIL
std/ranges/range.adaptors/range.transform/iterator/subscript.pass.cpp FAIL
std/ranges/range.utility/view.interface/view.interface.pass.cpp FAIL

Expand Down
2 changes: 0 additions & 2 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ utilities\memory\util.smartptr\util.smartptr.shared\util.smartptr.shared.const\u

# non-portable test of strengthened noexcept
ranges\range.adaptors\range.drop\ctor.default.pass.cpp
ranges\range.adaptors\range.transform\iterator\deref.pass.cpp
ranges\range.adaptors\range.transform\iterator\iter_move.pass.cpp
ranges\range.adaptors\range.transform\iterator\subscript.pass.cpp
ranges\range.utility\view.interface\view.interface.pass.cpp

Expand Down
4 changes: 2 additions & 2 deletions tests/std/tests/P0896R4_views_transform/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ struct iterator_instantiator {
auto r0 = make_view();
auto i0 = r0.begin();
assert(*i0 == add8(mutable_ints[0]));
STATIC_ASSERT(NOEXCEPT_IDL0(*i0));
STATIC_ASSERT(noexcept(*i0));

assert(ranges::iter_move(i0) == add8(mutable_ints[0])); // NB: moving from int leaves it unchanged
STATIC_ASSERT(NOEXCEPT_IDL0(ranges::iter_move(i0)));
STATIC_ASSERT(noexcept(ranges::iter_move(i0)));

STATIC_ASSERT(!CanIterSwap<decltype(i0)>);
}
Expand Down

0 comments on commit 05ac0a5

Please sign in to comment.