[libcxx-commits] [PATCH] D117329: [libc++] counted_iterator::base() const& should be noexcept.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 14 08:47:07 PST 2022
Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, Mordante, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
Drive-by: stop calling `.base()` on test iterators in the test.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117329
Files:
libcxx/include/__iterator/counted_iterator.h
libcxx/test/std/iterators/predef.iterators/counted.iterator/base.pass.cpp
Index: libcxx/test/std/iterators/predef.iterators/counted.iterator/base.pass.cpp
===================================================================
--- libcxx/test/std/iterators/predef.iterators/counted.iterator/base.pass.cpp
+++ libcxx/test/std/iterators/predef.iterators/counted.iterator/base.pass.cpp
@@ -32,17 +32,18 @@
{
std::counted_iterator iter(cpp20_input_iterator<int*>{buffer}, 8);
- assert(iter.base().base() == buffer);
- assert(std::move(iter).base().base() == buffer);
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
+ ASSERT_NOEXCEPT(iter.base());
ASSERT_SAME_TYPE(decltype(iter.base()), const cpp20_input_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), cpp20_input_iterator<int*>);
}
{
std::counted_iterator iter(forward_iterator<int*>{buffer}, 8);
- assert(iter.base() == forward_iterator<int*>{buffer});
- assert(std::move(iter).base() == forward_iterator<int*>{buffer});
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
ASSERT_SAME_TYPE(decltype(iter.base()), const forward_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), forward_iterator<int*>);
@@ -50,8 +51,8 @@
{
std::counted_iterator iter(contiguous_iterator<int*>{buffer}, 8);
- assert(iter.base() == contiguous_iterator<int*>{buffer});
- assert(std::move(iter).base() == contiguous_iterator<int*>{buffer});
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
ASSERT_SAME_TYPE(decltype(iter.base()), const contiguous_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), contiguous_iterator<int*>);
@@ -68,8 +69,8 @@
{
const std::counted_iterator iter(cpp20_input_iterator<int*>{buffer}, 8);
- assert(iter.base().base() == buffer);
- assert(std::move(iter).base().base() == buffer);
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
ASSERT_SAME_TYPE(decltype(iter.base()), const cpp20_input_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), const cpp20_input_iterator<int*>&);
@@ -77,8 +78,8 @@
{
const std::counted_iterator iter(forward_iterator<int*>{buffer}, 7);
- assert(iter.base() == forward_iterator<int*>{buffer});
- assert(std::move(iter).base() == forward_iterator<int*>{buffer});
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
ASSERT_SAME_TYPE(decltype(iter.base()), const forward_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), const forward_iterator<int*>&);
@@ -86,8 +87,8 @@
{
const std::counted_iterator iter(contiguous_iterator<int*>{buffer}, 6);
- assert(iter.base() == contiguous_iterator<int*>{buffer});
- assert(std::move(iter).base() == contiguous_iterator<int*>{buffer});
+ assert(base(iter.base()) == buffer);
+ assert(base(std::move(iter).base()) == buffer);
ASSERT_SAME_TYPE(decltype(iter.base()), const contiguous_iterator<int*>&);
ASSERT_SAME_TYPE(decltype(std::move(iter).base()), const contiguous_iterator<int*>&);
Index: libcxx/include/__iterator/counted_iterator.h
===================================================================
--- libcxx/include/__iterator/counted_iterator.h
+++ libcxx/include/__iterator/counted_iterator.h
@@ -96,7 +96,7 @@
}
_LIBCPP_HIDE_FROM_ABI
- constexpr const _Iter& base() const& { return __current_; }
+ constexpr const _Iter& base() const& noexcept { return __current_; }
_LIBCPP_HIDE_FROM_ABI
constexpr _Iter base() && { return _VSTD::move(__current_); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117329.400033.patch
Type: text/x-patch
Size: 3723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220114/ec3551b2/attachment.bin>
More information about the libcxx-commits
mailing list