[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
Mon Jan 31 10:10:19 PST 2022
philnik updated this revision to Diff 404591.
philnik added a comment.
- Add test
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
@@ -30,6 +30,12 @@
assert(!vec[1]);
assert(cref);
+ cref = false;
+ assert(!vec[0]);
+ assert(!vec[1]);
+ cref = true;
+ assert(vec[0]);
+ assert(!vec[1]);
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
@@ -25,7 +25,7 @@
static_assert( std::random_access_iterator<reverse_iterator>);
static_assert(!std::contiguous_iterator<iterator>);
static_assert(!std::contiguous_iterator<reverse_iterator>);
-static_assert(!std::indirectly_writable<iterator, value_type>);
+static_assert( std::indirectly_writable<iterator, value_type>);
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.404591.patch
Type: text/x-patch
Size: 2023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220131/b78fc161/attachment-0001.bin>
More information about the libcxx-commits
mailing list