[libcxx-commits] [PATCH] D117736: [libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 10 11:27:54 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb9646ed78a0: [libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const (authored by philnik).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117736/new/
https://reviews.llvm.org/D117736
Files:
libcxx/include/__bit_reference
libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp
libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
Index: libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
+++ libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
@@ -13,6 +13,8 @@
#include <cassert>
#include <vector>
+#include "test_macros.h"
+
bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
@@ -31,6 +33,15 @@
assert(cref);
+#if TEST_STD_VER > 20
+ cref = false;
+ assert(!vec[0]);
+ assert(!vec[1]);
+ cref = true;
+ assert(vec[0]);
+ assert(!vec[1]);
+#endif
+
return true;
}
Index: libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp
+++ libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp
@@ -11,9 +11,10 @@
// iterator, const_iterator, reverse_iterator, const_reverse_iterator
+#include <iterator>
#include <vector>
-#include <iterator>
+#include "test_macros.h"
using iterator = std::vector<bool>::iterator;
using const_iterator = std::vector<bool>::const_iterator;
@@ -25,7 +26,11 @@
static_assert( std::random_access_iterator<reverse_iterator>);
static_assert(!std::contiguous_iterator<iterator>);
static_assert(!std::contiguous_iterator<reverse_iterator>);
+#if TEST_STD_VER > 20
+static_assert( std::indirectly_writable<iterator, value_type>);
+#else
static_assert(!std::indirectly_writable<iterator, value_type>);
+#endif
static_assert( std::sentinel_for<iterator, iterator>);
static_assert( std::sentinel_for<iterator, const_iterator>);
static_assert(!std::sentinel_for<iterator, reverse_iterator>);
Index: libcxx/include/__bit_reference
===================================================================
--- libcxx/include/__bit_reference
+++ libcxx/include/__bit_reference
@@ -65,6 +65,16 @@
return *this;
}
+#if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
+ if (__x)
+ *__seg_ |= __mask_;
+ else
+ *__seg_ &= ~__mask_;
+ return *this;
+ }
+#endif
+
_LIBCPP_INLINE_VISIBILITY
__bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
{return operator=(static_cast<bool>(__x));}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117736.407617.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220210/85fbd0f7/attachment.bin>
More information about the libcxx-commits
mailing list