Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtCore/q23functional.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) 2022 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 // Qt-Security score:significant reason:default
0004 #ifndef Q23FUNCTIONAL_H
0005 #define Q23FUNCTIONAL_H
0006 
0007 #include <QtCore/qglobal.h>
0008 #include <QtCore/q20functional.h>
0009 
0010 //
0011 //  W A R N I N G
0012 //  -------------
0013 //
0014 // This file is not part of the Qt API. Types and functions defined in this
0015 // file can reliably be replaced by their std counterparts, once available.
0016 // You may use these definitions in your own code, but be aware that we
0017 // will remove them once Qt depends on the C++ version that supports
0018 // them in namespace std. There will be NO deprecation warning, the
0019 // definitions will JUST go away.
0020 //
0021 // If you can't agree to these terms, don't use these definitions!
0022 //
0023 // We mean it.
0024 //
0025 
0026 QT_BEGIN_NAMESPACE
0027 
0028 namespace q23 {
0029 // like std::invoke_r
0030 #ifdef __cpp_lib_invoke_r
0031 using std::invoke_r;
0032 #else
0033 template <typename R, typename F, typename...Args>
0034 constexpr
0035 std::enable_if_t<std::is_invocable_r_v<R, F, Args...>, R>
0036 invoke_r(F&& f, Args&&... args)
0037     noexcept(std::is_nothrow_invocable_r_v<R, F, Args...>)
0038 {
0039     // ### use q20::invoke for a constexpr std::invoke
0040     if constexpr (std::is_void_v<R>)
0041         std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
0042     else
0043         return std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
0044 }
0045 #endif // __cpp_lib_invoke_r
0046 } // namespace q23
0047 
0048 QT_END_NAMESPACE
0049 
0050 #endif /* Q23FUNCTIONAL_H */