Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
q17memory.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef Q17MEMORY_H
4#define Q17MEMORY_H
5
6#include <QtCore/qexceptionhandling.h>
7#include <QtCore/qtconfigmacros.h>
8
9#include <iterator>
10#include <memory>
11
12QT_BEGIN_NAMESPACE
13
14namespace q17 {
15// like std::uninitialized_value_construct
16#if !defined(Q_OS_VXWORKS)
17 using std::uninitialized_value_construct;
18#else
19 namespace _detail {
20 template <typename T>
21 void *voidify(T &t) {
22 // LWG3870 changed this for C++23, but this is q_17_, so use the C++17/20 version:
23 return const_cast<void*>(static_cast<const volatile void*>(std::addressof(t)));
24 }
25 } // namespace _detail
26 // WindRiver confirmed that implementation of `std::uninitialized_value_construct` is not
27 // working properly in VxWorks 24.03 (probably the same problem appears in older versions) with
28 // defect VXHVP-9969
29 template <typename ForwardIt>
31 {
32 auto current = first;
34 QT_TRY {
35 for (; current != last; ++current)
36 ::new (_detail::voidify(*current)) ValueType();
37 } QT_CATCH(...) {
40 }
41 }
42#endif // Q_OS_VXWORKS
43} // namespace q17
44
45QT_END_NAMESPACE
46
47#endif // Q17MEMORY_H