6#include <QtCore/qglobal.h>
24#include <QtCore/q23functional.h>
25#include <QtCore/q20type_traits.h>
48using if_function = std::enable_if_t<std::is_function_v<T>,
bool>;
52template <
typename From,
typename To>
54 std::is_const_v<From>,
61 template <
typename F, if_function<F> = true>
63 :
fun(reinterpret_cast<QFunctionPointer>(
f)) {}
64 template <
typename T, if_non_function<T> = true>
66 :
obj(static_cast<Const*>(
t)) {}
71template <
bool noex,
class Const,
class R,
class... ArgTypes>
79 template <
typename... Ts>
82 std::is_nothrow_invocable_r<
R, Ts..., ArgTypes...>,
83 std::is_invocable_r<
R, Ts..., ArgTypes...>
94 std::enable_if_t<std::conjunction_v<
102 return q23::invoke_r<R>(
reinterpret_cast<F*
>(
ctx.fun),
103 std::forward<ArgTypes>(
args)...);
109 std::enable_if_t<std::conjunction_v<
110 std::negation<std::is_same<q20::remove_cvref_t<F>, function_ref_base>>,
111 std::negation<std::is_member_pointer<std::remove_reference_t<F>>>,
112 is_invocable_using<copy_const_t<Const, std::remove_reference_t<F>>&>
119 return q23::invoke_r<R>(*
static_cast<That*
>(
ctx.obj),
120 std::forward<ArgTypes>(
args)...);
127 std::enable_if_t<std::conjunction_v<
128 std::negation<std::is_same<q20::remove_cvref_t<T>, function_ref_base>>,
129 std::negation<std::is_pointer<T>>
144#define QT_SPECIALIZE_FUNCTION_REF(cv, noex) \
145 template<class R, class... ArgTypes> \
146 class function_ref<R(ArgTypes...) cv noexcept( noex )> \
147 : private detail::function_ref_base< noex , cv void, R, ArgTypes...> \
149 using base = detail::function_ref_base< noex , cv void, R, ArgTypes...>; \
153 using base::operator(); \
162#undef QT_SPECIALIZE_FUNCTION_REF
168 std::enable_if_t<std::is_function_v<F>,
bool> =
true
R(*)(BoundEntityType, ArgTypes &&...) noexcept(noex) ThunkPtr
R operator()(ArgTypes... args) const noexcept(noex)
~function_ref_base()=default
function_ref_base & operator=(T)=delete
detail::BoundEntityType< Const > BoundEntityType
std::conditional_t< noex, std::is_nothrow_invocable_r< R, Ts..., ArgTypes... >, std::is_invocable_r< R, Ts..., ArgTypes... > > is_invocable_using
Q_IMPLICIT constexpr function_ref_base(F &&f) noexcept
BoundEntityType m_bound_entity
Q_IMPLICIT function_ref_base(F *f) noexcept
Combined button and popup list for selecting options.
std::conditional_t< std::is_const_v< From >, std::add_const_t< To >, To > copy_const_t
std::enable_if_t< std::is_function_v< T >, bool > if_function
std::enable_if_t<!std::is_function_v< T >, bool > if_non_function
#define QT_SPECIALIZE_FUNCTION_REF(cv, noex)
constexpr BoundEntityType(F *f)
constexpr BoundEntityType(T *t)