[libcxx-commits] [libcxx] 0edc92e - [libc++] LWG3738 Validates a missing precondition.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 23 08:21:04 PST 2022
Author: Mark de Wever
Date: 2022-12-23T17:20:57+01:00
New Revision: 0edc92e6e098e66e452a730f524b0905e2d4c78b
URL: https://github.com/llvm/llvm-project/commit/0edc92e6e098e66e452a730f524b0905e2d4c78b
DIFF: https://github.com/llvm/llvm-project/commit/0edc92e6e098e66e452a730f524b0905e2d4c78b.diff
LOG: [libc++] LWG3738 Validates a missing precondition.
No real changes were needed, but add an assert for the pre-condition.
This implements:
- 3738 Missing preconditions for take_view constructor
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D140568
Added:
Modified:
libcxx/docs/Status/Cxx2bIssues.csv
libcxx/include/__ranges/take_view.h
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv
index 3a6d2c8fff2a2..8171ce30c1c24 100644
--- a/libcxx/docs/Status/Cxx2bIssues.csv
+++ b/libcxx/docs/Status/Cxx2bIssues.csv
@@ -203,7 +203,7 @@
"`3732 <https://wg21.link/LWG3732>`__","``prepend_range`` and ``append_range`` can't be amortized constant time", "November 2022","|Nothing to do|","","|ranges|"
"`3736 <https://wg21.link/LWG3736>`__","``move_iterator`` missing ``disable_sized_sentinel_for`` specialization", "November 2022","","","|ranges|"
"`3737 <https://wg21.link/LWG3737>`__","``take_view::sentinel`` should provide ``operator-``", "November 2022","","","|ranges|"
-"`3738 <https://wg21.link/LWG3738>`__","Missing preconditions for ``take_view`` constructor", "November 2022","","","|ranges|"
+"`3738 <https://wg21.link/LWG3738>`__","Missing preconditions for ``take_view`` constructor", "November 2022","|Complete|","16.0","|ranges|"
"`3743 <https://wg21.link/LWG3743>`__","``ranges::to``'s reserve may be ill-formed", "November 2022","","","|ranges|"
"`3745 <https://wg21.link/LWG3745>`__","``std::atomic_wait`` and its friends lack ``noexcept``", "November 2022","|Complete|","16.0",""
"`3746 <https://wg21.link/LWG3746>`__","``optional``'s spaceship with ``U`` with a type derived from optional causes infinite constraint meta-recursion", "November 2022","","","|spaceship|"
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 546e898aec911..bea3862cd7c8c 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -12,6 +12,7 @@
#include <__algorithm/min.h>
#include <__algorithm/ranges_min.h>
+#include <__assert>
#include <__concepts/constructible.h>
#include <__concepts/convertible_to.h>
#include <__config>
@@ -63,9 +64,10 @@ class take_view : public view_interface<take_view<_View>> {
_LIBCPP_HIDE_FROM_ABI
take_view() requires default_initializable<_View> = default;
- _LIBCPP_HIDE_FROM_ABI
- constexpr take_view(_View __base, range_
diff erence_t<_View> __count)
- : __base_(std::move(__base)), __count_(__count) {}
+ _LIBCPP_HIDE_FROM_ABI constexpr take_view(_View __base, range_
diff erence_t<_View> __count)
+ : __base_(std::move(__base)), __count_(__count) {
+ _LIBCPP_ASSERT(__count >= 0, "count has to be greater than or equal to zero");
+ }
_LIBCPP_HIDE_FROM_ABI
constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
More information about the libcxx-commits
mailing list