1// Copyright (C) 2021 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
4#ifndef QQMLDOMFUNCTIONREF_P_H
5#define QQMLDOMFUNCTIONREF_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19
20#if !defined(Q_CC_MSVC) || Q_CC_MSVC >= 1930
21#include <QtCore/qxpfunctional.h>
22
23QT_BEGIN_NAMESPACE
24namespace QQmlJS {
25namespace Dom {
26template <typename T>
27using function_ref = qxp::function_ref<T>;
28} // namespace Dom
29} // namespace QQmlJS
30QT_END_NAMESPACE
31
32#else
33
34#include <functional>
35
36QT_BEGIN_NAMESPACE
37namespace QQmlJS {
38namespace Dom {
39namespace _detail {
40template <typename T>
41struct function_ref_helper { using type = std::function<T>; };
42// std::function doesn't grok the const in <int(int) const>, so remove:
43template <typename R, typename...Args>
44struct function_ref_helper<R(Args...) const> : function_ref_helper<R(Args...)> {};
45// std::function doesn't grok the noexcept in <int(int) noexcept>, so remove:
46template <typename R, typename...Args>
47struct function_ref_helper<R(Args...) noexcept> : function_ref_helper<R(Args...)> {};
48// and both together:
49template <typename R, typename...Args>
50struct function_ref_helper<R(Args...) const noexcept> : function_ref_helper<R(Args...)> {};
51} // namespace _detail
52template <typename T>
53using function_ref = const typename _detail::function_ref_helper<T>::type &;
54} // namespace Dom
55} // namespace QQmlJS
56QT_END_NAMESPACE
57
58#endif
59
60#endif // QQMLDOMFUNCTIONREF_P_H
61

source code of qtdeclarative/src/qmldom/qqmldomfunctionref_p.h