Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtCore/q17memory.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2024 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 #ifndef Q17MEMORY_H
0004 #define Q17MEMORY_H
0005 
0006 #include <QtCore/qexceptionhandling.h>
0007 #include <QtCore/qtconfigmacros.h>
0008 
0009 #include <iterator>
0010 #include <memory>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 namespace q17 {
0015 // like std::uninitialized_value_construct
0016 #if !defined(Q_OS_VXWORKS)
0017     using std::uninitialized_value_construct;
0018 #else
0019     namespace _detail {
0020         template <typename T>
0021         void *voidify(T &t) {
0022             // LWG3870 changed this for C++23, but this is q_17_, so use the C++17/20 version:
0023             return const_cast<void*>(static_cast<const volatile void*>(std::addressof(t)));
0024         }
0025     } // namespace _detail
0026     // WindRiver confirmed that implementation of `std::uninitialized_value_construct` is not
0027     // working properly in VxWorks 24.03 (probably the same problem appears in older versions) with
0028     // defect VXHVP-9969
0029     template <typename ForwardIt>
0030     void uninitialized_value_construct(ForwardIt first, ForwardIt last)
0031     {
0032         auto current = first;
0033         using ValueType = typename std::iterator_traits<ForwardIt>::value_type;
0034         QT_TRY {
0035             for (; current != last; ++current)
0036                 ::new (_detail::voidify(*current)) ValueType();
0037         } QT_CATCH(...) {
0038             std::destroy(first, current);
0039             QT_RETHROW;
0040         }
0041     }
0042 #endif // Q_OS_VXWORKS
0043 } // namespace q17
0044 
0045 QT_END_NAMESPACE
0046 
0047 #endif // Q17MEMORY_H