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
26QT_BEGIN_NAMESPACE
27
28namespace q20 {
29// like std::remove_cvref(_t)
30#ifdef __cpp_lib_remove_cvref
31using std::remove_cvref;
32using std::remove_cvref_t;
33#else
34template <typename T>
35using remove_cvref = std::remove_cv<std::remove_reference_t<T>>;
36template <typename T>
37using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
38#endif // __cpp_lib_remove_cvref
39}
40
41namespace q20 {
42// like std::type_identity(_t)
43#ifdef __cpp_lib_type_identity
44using std::type_identity;
45using std::type_identity_t;
46#else
47template <typename T>
48struct type_identity { using type = T; };
49template <typename T>
50using type_identity_t = typename type_identity<T>::type;
51#endif // __cpp_lib_type_identity
52}
53
54QT_END_NAMESPACE
55
56#endif /* Q20TYPE_TRAITS_H */
57

source code of qtbase/src/corelib/global/q20type_traits.h