14 #include <type_traits>
36 constexpr TypeMarker() =
default;
42 constexpr
size_t get_arity()
44 return get_arity(TypeMarker<std::decay_t<T>>{});
50 constexpr
size_t get_arity(
const T &)
52 return get_arity<T>();
56 template<
typename Return,
typename... Arguments>
57 constexpr
size_t get_arity(TypeMarker<Return (*)(Arguments...)>)
59 return sizeof...(Arguments);
62 template<
typename Return,
typename... Arguments>
63 constexpr
size_t get_arity(TypeMarker<Return (*)(Arguments...) noexcept>)
65 return sizeof...(Arguments);
71 constexpr
size_t get_arity(TypeMarker<T>)
73 return get_arity(TypeMarker<decltype(&T::operator())>{}) - 1;
78 #define KDBINDINGS_DEFINE_MEMBER_GET_ARITY(MODIFIERS) \
79 template<typename Return, typename Class, typename... Arguments> \
80 constexpr size_t get_arity(::KDBindings::Private::TypeMarker<Return (Class::*)(Arguments...) MODIFIERS>) \
82 return sizeof...(Arguments) + 1; \
87 template<
typename Return,
typename Class,
typename... Arguments>
88 constexpr
size_t get_arity(::KDBindings::Private::TypeMarker<Return (Class::*)(Arguments...)>)
90 return sizeof...(Arguments) + 1;
130 template<
typename Func,
typename... Args, std::size_t... Is>
131 auto bind_first_helper(std::index_sequence<Is...>, Func &&fun, Args... args)
133 return std::bind(std::forward<Func>(fun), std::forward<Args>(args)..., placeholder<Is + 1>{}...);
151 typename = std::enable_if_t<std::conjunction_v<std::negation<std::is_placeholder<Args>>...>>>
152 auto bind_first(Func &&fun, Args &&...args)
154 return bind_first_helper(std::make_index_sequence<get_arity<Func>() -
sizeof...(Args)>{}, std::forward<Func>(fun), std::forward<Args>(args)...);
165 struct is_placeholder<
KDBindings::Private::placeholder<N>>
166 : integral_constant<int, N> {
The main namespace of the KDBindings library.
#define KDBINDINGS_DEFINE_MEMBER_GET_ARITY(MODIFIERS)