![]() This implements the changes in P2231R1 which make std::variant fully constexpr in C++20. We need to replace placement new with std::construct_at, but that isn't defined for C++17. Use std::_Construct instead, which forwards to std::construct_at in C++20 mode (since the related changes to make std::optional fully constexpr, in r12-4389). We also need to replace the untyped char buffer in _Uninitialized with a union, which can be accessed in constexpr functions. But the union needs to have a non-trivial destructor if its variant type is non-trivial, which means that the _Variadic_union also needs a non-trivial destructor. This adds a constrained partial specialization of _Variadic_union for the C++20-only case where a non-trivial destructor is needed. We can't use concepts to constrain the specialization (or the primary template's destructor) in C++17, so retain the untyped char buffer solution for C++17 mode. libstdc++-v3/ChangeLog: * include/std/variant (__cpp_lib_variant): Update value for C++20. (__variant_cast, __variant_construct): Add constexpr for C++20. (__variant_construct_single, __construct_by_index) Likewise. Use std::_Construct instead of placement new. (_Uninitialized<T, false>) [__cplusplus >= 202002]: Replace buffer with a union and define a destructor. (_Variadic_union) [__cplusplus >= 202002]: Add a specialization for non-trivial destruction. (_Variant_storage::__index_of): New helper variable template. (_Variant_storage::~_Variant_storage()): Add constexpr. (_Variant_storage::_M_reset()): Likewise. (_Copy_ctor_base, _Move_ctor_base): Likewise. (_Copy_assign_base, _Move_assign_base): Likewise. (variant, swap): Likewise. * include/std/version (__cpp_lib_variant): Update value for C++20. * testsuite/20_util/optional/version.cc: Check for exact value in C++17. * testsuite/20_util/variant/87619.cc: Increase timeout for C++20 mode. * testsuite/20_util/variant/constexpr.cc: New test. * testsuite/20_util/variant/version.cc: New test. |
||
---|---|---|
.. | ||
config | ||
doc | ||
include | ||
libsupc++ | ||
po | ||
python | ||
scripts | ||
src | ||
testsuite | ||
acinclude.m4 | ||
aclocal.m4 | ||
ChangeLog | ||
ChangeLog-1998 | ||
ChangeLog-1999 | ||
ChangeLog-2000 | ||
ChangeLog-2001 | ||
ChangeLog-2002 | ||
ChangeLog-2003 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog-2018 | ||
ChangeLog-2019 | ||
ChangeLog-2020 | ||
config.h.in | ||
configure | ||
configure.ac | ||
configure.host | ||
crossconfig.m4 | ||
fragment.am | ||
linkage.m4 | ||
Makefile.am | ||
Makefile.in | ||
README |
file: libstdc++-v3/README New users may wish to point their web browsers to the file index.html in the 'doc/html' subdirectory. It contains brief building instructions and notes on how to configure the library in interesting ways.