[libcxx-commits] [PATCH] D145257: [libc++] Fixes basic_string operator& hijacking.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 7 09:09:52 PST 2023


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Nice catch -- it would be nice to improve the remaining `std::string` tests similarly.



================
Comment at: libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp:23
 template <class S>
-TEST_CONSTEXPR_CXX20 void
-test(S s, S str, S expected)
-{
-    s.assign(str);
-    LIBCPP_ASSERT(s.__invariants());
-    assert(s == expected);
+TEST_CONSTEXPR_CXX20 void test(S s, S str) {
+  s.assign(str);
----------------
Maybe?


================
Comment at: libcxx/test/support/nasty_string.h:19-21
+// Like the nasty_containsers this defines a nasty_string. This string's
+// value_type does operator hijacking. This makes guards against unsign the
+// value_type directly, since operations should use the traits.
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145257/new/

https://reviews.llvm.org/D145257



More information about the libcxx-commits mailing list