[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
Tue Oct 5 17:00:16 PDT 2021


jloser updated this revision to Diff 377393.
jloser added a comment.

Explicitly include <type_traits> in tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111197

Files:
  libcxx/test/std/containers/views/trivially_copyable.compile.pass.cpp
  libcxx/test/std/strings/string.view/trivially_copyable.compile.pass.cpp


Index: libcxx/test/std/strings/string.view/trivially_copyable.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/strings/string.view/trivially_copyable.compile.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+#include <string_view>
+#include <type_traits>
+
+static_assert(std::is_trivially_copyable_v<std::basic_string_view<char>>);
+static_assert(std::is_trivially_copyable_v<std::basic_string_view<wchar_t>>);
+static_assert(std::is_trivially_copyable_v<std::basic_string_view<char8_t>>);
+static_assert(std::is_trivially_copyable_v<std::basic_string_view<char16_t>>);
+static_assert(std::is_trivially_copyable_v<std::basic_string_view<char32_t>>);
Index: libcxx/test/std/containers/views/trivially_copyable.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/containers/views/trivially_copyable.compile.pass.cpp
@@ -0,0 +1,23 @@
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <span>
+
+#include <span>
+#include <type_traits>
+
+static_assert(std::is_trivially_copyable_v<std::span<int>>);
+static_assert(std::is_trivially_copyable_v<std::span<int, 3>>);
+
+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>>);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111197.377393.patch
Type: text/x-patch
Size: 2152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211006/b8c069e9/attachment.bin>


More information about the libcxx-commits mailing list