QKeySequence: fix dynamic initialization of shared_empty

The QKeySequencePrivate default constructor wasn't constexpr, so
shared_empty was not constinit'able. To make the constructor
constexpr in C++17 as well as C++20, needed to replace the fill_n()
on the key member with Uniform Initialization.

Found by attempting to apply C++20 constinit to its definition.

Pick-to: 6.3 6.2
Change-Id: I2941e96348eb969029da2f0f7231079967bba996
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Marc Mutz 2022-05-19 10:38:48 +02:00
parent 562f1387cb
commit 402ce8f266

View File

@ -36,10 +36,7 @@ class QKeySequencePrivate
{
public:
enum { MaxKeyCount = 4 }; // also used in QKeySequenceEdit
inline QKeySequencePrivate() : ref(1)
{
std::fill_n(key, uint(MaxKeyCount), 0);
}
constexpr QKeySequencePrivate() : ref(1), key{} {}
inline QKeySequencePrivate(const QKeySequencePrivate &copy) : ref(1)
{
std::copy(copy.key, copy.key + MaxKeyCount,