[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 16:59:09 PDT 2021
jloser created this revision.
jloser added reviewers: ldionne, Quuxplusone, Mordante.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Implement P2251 <https://reviews.llvm.org/P2251> which requires `span` and `basic_string_view` to be
trivially copyable.
Repository:
rG LLVM Github Monorepo
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,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+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,22 @@
+//
+// 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>
+
+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.377392.patch
Type: text/x-patch
Size: 2104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211005/85b85cba/attachment.bin>
More information about the libcxx-commits
mailing list