[libcxx-commits] [PATCH] D122092: [libc++] `bitset::operator[] const` should return bool
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 29 08:24:04 PDT 2022
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
LGTM with changes, thanks!
================
Comment at: libcxx/include/__config:117
# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
+// According to the standard `bitset::operator[] const` returns bool
+# define _LIBCPP_ABI_BITSET_CONST_SUBSCRIPT_RETURN_BOOL
----------------
================
Comment at: libcxx/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp:46-55
+ std::bitset<1> set_;
+ set_[0] = false;
+ const auto& set = set_;
+ auto b = set[0];
+ set_[0] = true;
+#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_ABI_BITSET_CONST_SUBSCRIPT_RETURN_BOOL)
+ assert(!b);
----------------
Can you add the same test to the non-const `operator[]` (but you'll only have one `assert`)?
Also, I'd recommend against using `#endif // comment` since this block is so short -- in this case it's even wrong.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122092/new/
https://reviews.llvm.org/D122092
More information about the libcxx-commits
mailing list