From 1fa935d93e21a96e0cf42c38bebd5a99aab4be9d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Jan 2023 10:50:51 +0100 Subject: [PATCH] Short live q20::construct_at()! Move the helper from qsystemsemaphore.cpp to q20memory.h to prevent clashes in CMake Unity (Jumbo) builds. Manual conflict resolutions: - file-local construct_at doesn't exist in 6.5 Task-number: QTBUG-109394 Change-Id: Id0127af1f0d51c87a5887090cc90ab232eff8093 Reviewed-by: Thiago Macieira Reviewed-by: Qt CI Bot (cherry picked from commit 72c2cdbc572f8b8b45a57a451e2bc19bb1c53b0c) Reviewed-by: Friedemann Kleint Reviewed-by: Marc Mutz --- src/corelib/CMakeLists.txt | 1 + src/corelib/global/q20memory.h | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/corelib/global/q20memory.h diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 56daff4f836..59362e02f48 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -103,6 +103,7 @@ qt_internal_add_module(Core global/q20algorithm.h global/q20functional.h global/q20iterator.h + global/q20memory.h global/q20type_traits.h global/q23functional.h global/qxpfunctional.h diff --git a/src/corelib/global/q20memory.h b/src/corelib/global/q20memory.h new file mode 100644 index 00000000000..438613db48b --- /dev/null +++ b/src/corelib/global/q20memory.h @@ -0,0 +1,46 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef Q20MEMORY_H +#define Q20MEMORY_H + +#include + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. Types and functions defined in this +// file can reliably be replaced by their std counterparts, once available. +// You may use these definitions in your own code, but be aware that we +// will remove them once Qt depends on the C++ version that supports +// them in namespace std. There will be NO deprecation warning, the +// definitions will JUST go away. +// +// If you can't agree to these terms, don't use these definitions! +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +namespace q20 { + +#if __cplusplus >= 202002L +using std::construct_at; +#else +template ()) T(std::declval()...))> > + static void construct_at(T *ptr, Args && ... args) +{ + ::new (const_cast(static_cast(ptr))) T(std::forward(args)...); +} +#endif +} // namespace q20 + +QT_END_NAMESPACE + +#endif /* Q20MEMORY_H */