diff --git a/src/corelib/global/q20memory.h b/src/corelib/global/q20memory.h index 438613db48b..bb337a9f7f2 100644 --- a/src/corelib/global/q20memory.h +++ b/src/corelib/global/q20memory.h @@ -4,9 +4,12 @@ #ifndef Q20MEMORY_H #define Q20MEMORY_H -#include +#include #include +#include + +#include // // W A R N I N G @@ -26,19 +29,20 @@ QT_BEGIN_NAMESPACE +// like std::construct_at (but not whitelisted for constexpr) namespace q20 { - -#if __cplusplus >= 202002L +#ifdef __cpp_lib_constexpr_dynamic_alloc using std::construct_at; #else template ()) T(std::declval()...))> > - static void construct_at(T *ptr, Args && ... args) +T *construct_at(T *ptr, Args && ... args) { - ::new (const_cast(static_cast(ptr))) T(std::forward(args)...); + return ::new (const_cast(static_cast(ptr))) + T(std::forward(args)...); } -#endif +#endif // __cpp_lib_constexpr_dynamic_alloc } // namespace q20 QT_END_NAMESPACE