Commit deb9c51c by Ville Voutilainen

PR libstdc++/95915

	PR libstdc++/95915
	* include/std/variant (_Uninitialized):
	Adjust the condition and the comment.
	* testsuite/20_util/variant/95915.cc: New.
	* testsuite/20_util/variant/compile.cc: Add new test.

(cherry picked from commit 24b54628cfa95194a8de4071c28cb56e6e81c08e)
parent 62175c50
......@@ -202,15 +202,9 @@ namespace __variant
std::forward<_Variants>(__variants)...);
}
// _Uninitialized<T> is guaranteed to be a literal type, even if T is not.
// We have to do this, because [basic.types]p10.5.3 (n4606) is not implemented
// yet. When it's implemented, _Uninitialized<T> can be changed to the alias
// to T, therefore equivalent to being removed entirely.
//
// Another reason we may not want to remove _Uninitialzied<T> may be that, we
// want _Uninitialized<T> to be trivially destructible, no matter whether T
// is; but we will see.
template<typename _Type, bool = std::is_literal_type_v<_Type>>
// _Uninitialized<T> is guaranteed to be a trivially destructible type,
// even if T is not.
template<typename _Type, bool = std::is_trivially_destructible_v<_Type>>
struct _Uninitialized;
template<typename _Type>
......
// { dg-options "-std=gnu++20" }
// { dg-do compile { target c++20 } }
// Copyright (C) 2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <variant>
using namespace std;
struct virtual_default_dtor {
virtual ~virtual_default_dtor() = default;
};
void default_ctor()
{
{
variant<virtual_default_dtor> a;
}
}
......@@ -84,6 +84,10 @@ struct nonliteral
bool operator>(const nonliteral&) const;
};
struct virtual_default_dtor {
virtual ~virtual_default_dtor() = default;
};
void default_ctor()
{
static_assert(is_default_constructible_v<variant<int, string>>);
......@@ -95,6 +99,9 @@ void default_ctor()
static_assert(noexcept(variant<int>()));
static_assert(!noexcept(variant<Empty>()));
static_assert(noexcept(variant<DefaultNoexcept>()));
{
variant<virtual_default_dtor> a;
}
}
void copy_ctor()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment