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 Q20FUNCTIONAL_H
4#define Q20FUNCTIONAL_H
5
6#include <QtCore/qglobal.h>
7
8#include <functional>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. Types and functions defined in this
15// file can reliably be replaced by their std counterparts, once available.
16// You may use these definitions in your own code, but be aware that we
17// will remove them once Qt depends on the C++ version that supports
18// them in namespace std. There will be NO deprecation warning, the
19// definitions will JUST go away.
20//
21// If you can't agree to these terms, don't use these definitions!
22//
23// We mean it.
24//
25
26#include <functional>
27
28QT_BEGIN_NAMESPACE
29
30namespace q20 {
31// like std::identity
32#ifdef __cpp_lib_ranges
33using std::identity;
34#else
35struct identity
36{
37 struct is_transparent {};
38 template <typename T>
39 constexpr T &&operator()(T&& t) const noexcept { return std::forward<T>(t); }
40};
41#endif // __cpp_lib_ranges
42} // namespace q20
43
44QT_END_NAMESPACE
45
46#endif /* Q20FUNCTIONAL_H */
47

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