[libcxx-commits] [PATCH] D111197: [libc++] Verify span and string_view are trivially copyable

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 6 07:05:24 PDT 2021


jloser added inline comments.


================
Comment at: libcxx/test/std/containers/views/trivially_copyable.compile.pass.cpp:18-23
+struct UserDefinedNonTrival {
+  UserDefinedNonTrival() {}
+  UserDefinedNonTrival(const UserDefinedNonTrival&) {}
+};
+static_assert(std::is_trivially_copyable_v<std::span<UserDefinedNonTrival>>);
+static_assert(std::is_trivially_copyable_v<std::span<UserDefinedNonTrival, 3>>);
----------------
Quuxplusone wrote:
> (1) s/Trival/Trivial/g
> (2) I don't think lines 18–23 are needed at all. We can trust that `span` doesn't do anything stupidly depending on the type-the-pointer-points-to.
Removed them - I agree it was a bit far. For example, I thought about adding an evil custom char traits class to use as a template in the other test for `string_view`, but I thought it was a bit overkill.


================
Comment at: libcxx/test/std/strings/string.view/trivially_copyable.compile.pass.cpp:9
+
+// <string_view>
+
----------------
Quuxplusone wrote:
> This surely needs some `// UNSUPPORTED: c++03, c++11, c++14`, but buildkite will tell you for sure.
> ...Actually, it looks like libc++ supports `string_view` as an extension all the way back to C++03? is that true? So you'll want to use `static_assert(std::is_trivially_copyable<...>::value, "");` below.
Seems to be the case that `libc++` supports `string_view` all the way back to C++03 oddly enough. Just fixed up the `static_assert`s to play nicely with older modes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111197



More information about the libcxx-commits mailing list