[libcxx] Make std::tuple<> trivially constructible
Summary:
This is not mandated by the Standard, but it's nonetheless a nice
property to have, especially since it's so easy to implement. It
also shrinks our bug list!
PR41714
Reviewers: mclow.lists, EricWF
Subscribers: christof, jkorous, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D62618
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@363075 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/tuple b/include/tuple
index 7437d5c..b283666 100644
--- a/include/tuple
+++ b/include/tuple
@@ -907,7 +907,7 @@
{
public:
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR tuple() _NOEXCEPT = default;
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
diff --git a/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/empty_tuple_trivial.pass.cpp b/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/empty_tuple_trivial.pass.cpp
new file mode 100644
index 0000000..a8d7152
--- /dev/null
+++ b/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/empty_tuple_trivial.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
+//
+//===----------------------------------------------------------------------===//
+
+// This test ensures that std::tuple<> is trivially constructible. That is not
+// required by the Standard, but libc++ provides that guarantee.
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <type_traits>
+
+
+static_assert(std::is_trivially_constructible<std::tuple<>>::value, "");
+
+int main(int, char**) {
+ return 0;
+}