Fixes PR21157 'tuple: non-default constructible tuple hard failure' Thanks to Louis Dionne for the bug report and the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@219785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,9 +16,23 @@
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#include "DefaultOnly.h"
|
||||
|
||||
struct NoDefault {
|
||||
NoDefault() = delete;
|
||||
explicit NoDefault(int) { }
|
||||
};
|
||||
|
||||
struct NoExceptDefault {
|
||||
NoExceptDefault() noexcept = default;
|
||||
};
|
||||
|
||||
struct ThrowingDefault {
|
||||
ThrowingDefault() { }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -46,6 +60,20 @@ int main()
|
||||
assert(std::get<2>(t) == "");
|
||||
assert(std::get<3>(t) == DefaultOnly());
|
||||
}
|
||||
{
|
||||
// See bug #21157.
|
||||
static_assert(!std::is_default_constructible<std::tuple<NoDefault>>(), "");
|
||||
static_assert(!std::is_default_constructible<std::tuple<DefaultOnly, NoDefault>>(), "");
|
||||
static_assert(!std::is_default_constructible<std::tuple<NoDefault, DefaultOnly, NoDefault>>(), "");
|
||||
}
|
||||
{
|
||||
static_assert(noexcept(std::tuple<NoExceptDefault>()), "");
|
||||
static_assert(noexcept(std::tuple<NoExceptDefault, NoExceptDefault>()), "");
|
||||
|
||||
static_assert(!noexcept(std::tuple<ThrowingDefault, NoExceptDefault>()), "");
|
||||
static_assert(!noexcept(std::tuple<NoExceptDefault, ThrowingDefault>()), "");
|
||||
static_assert(!noexcept(std::tuple<ThrowingDefault, ThrowingDefault>()), "");
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
{
|
||||
constexpr std::tuple<> t;
|
||||
|
Reference in New Issue
Block a user