Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:14

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