1 | // Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | #ifndef Q20TYPE_TRAITS_H |
4 | #define Q20TYPE_TRAITS_H |
5 | |
6 | #include <QtCore/qtconfigmacros.h> |
7 | |
8 | // |
9 | // W A R N I N G |
10 | // ------------- |
11 | // |
12 | // This file is not part of the Qt API. Types and functions defined in this |
13 | // file can reliably be replaced by their std counterparts, once available. |
14 | // You may use these definitions in your own code, but be aware that we |
15 | // will remove them once Qt depends on the C++ version that supports |
16 | // them in namespace std. There will be NO deprecation warning, the |
17 | // definitions will JUST go away. |
18 | // |
19 | // If you can't agree to these terms, don't use these definitions! |
20 | // |
21 | // We mean it. |
22 | // |
23 | |
24 | #include <type_traits> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | namespace q20 { |
29 | // like std::remove_cvref(_t) |
30 | #ifdef __cpp_lib_remove_cvref |
31 | using std::remove_cvref; |
32 | using std::remove_cvref_t; |
33 | #else |
34 | template <typename T> |
35 | using remove_cvref = std::remove_cv<std::remove_reference_t<T>>; |
36 | template <typename T> |
37 | using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>; |
38 | #endif // __cpp_lib_remove_cvref |
39 | } |
40 | |
41 | namespace q20 { |
42 | // like std::type_identity(_t) |
43 | #ifdef __cpp_lib_type_identity |
44 | using std::type_identity; |
45 | using std::type_identity_t; |
46 | #else |
47 | template <typename T> |
48 | struct type_identity { using type = T; }; |
49 | template <typename T> |
50 | using type_identity_t = typename type_identity<T>::type; |
51 | #endif // __cpp_lib_type_identity |
52 | } |
53 | |
54 | QT_END_NAMESPACE |
55 | |
56 | #endif /* Q20TYPE_TRAITS_H */ |
57 | |