[libcxx-commits] [PATCH] D108827: [libc++] Add an assertion in the subrange constructors with a size hint
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 31 07:23:12 PDT 2021
ldionne updated this revision to Diff 369694.
ldionne marked an inline comment as done.
ldionne added a comment.
Adjust condition
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108827/new/
https://reviews.llvm.org/D108827
Files:
libcxx/include/__ranges/subrange.h
Index: libcxx/include/__ranges/subrange.h
===================================================================
--- libcxx/include/__ranges/subrange.h
+++ libcxx/include/__ranges/subrange.h
@@ -118,7 +118,12 @@
constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent,
make_unsigned_t<iter_difference_t<_Iter>> __n)
requires (_Kind == subrange_kind::sized)
- : _Base(_VSTD::move(__iter), __sent, __n) { }
+ : _Base(_VSTD::move(__iter), __sent, __n)
+ {
+ if constexpr (sized_sentinel_for<_Sent, _Iter>)
+ _LIBCPP_ASSERT((this->__end_ - this->__begin_) == static_cast<iter_difference_t<_Iter>>(__n),
+ "std::ranges::subrange was passed an invalid size hint");
+ }
template<__different_from<subrange> _Range>
requires borrowed_range<_Range> &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108827.369694.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210831/db260585/attachment.bin>
More information about the libcxx-commits
mailing list