13#ifndef __AUDACITY_CALLABLE__
14#define __AUDACITY_CALLABLE__
31 R
operator()(Args... args)
const {
return f(std::forward<Args>(args)...); }
37 template<
typename T>
using Result = std::invoke_result_t<Member, T>;
38 template<
typename,
typename =
void>
struct CanAccept : std::false_type {};
49 return std::invoke(
member, std::forward<Obj>(obj));
56 using type =
typename std::conditional_t<std::is_class_v<Invocable>,
73 template<
typename...
Is>
97 static auto Function(Arguments... arguments) -> std::unique_ptr<Type>
99 return std::make_unique<Type>(std::forward<Arguments&&>(arguments)...);
106 static auto Function(Arguments... arguments) -> std::shared_ptr<Type>
108 return std::make_shared<Type>(std::forward<Arguments&&>(arguments)...);
113template<
auto Value,
typename... Arguments>
struct Constantly {
114 static decltype(Value)
Function (Arguments...) {
return Value; }
122template<
typename T,
typename... FixedArgs>
constexpr auto UniqueMaker() {
123 return [](FixedArgs... fixedArgs,
auto&&... args) {
124 return std::make_unique<T>(
125 std::forward<FixedArgs>(fixedArgs)...,
126 std::forward<
decltype(args)>(args)...);
typename InvocableBase< Invocable >::type InvocableBase_t
OverloadSet(Is &&... invocables) -> OverloadSet< Is &&... >
constexpr auto UniqueMaker()
Generate variadic factory functions.
Call< Predicate, T > Is
Apply a metapredicate to a type.
Generates functions useable as non-type template parameters.
static decltype(Value) Function(Arguments...)
Generates functions useable as non-type template parameters.
static auto Function(Arguments... arguments) -> std::shared_ptr< Type >
Generates functions useable as non-type template parameters.
static auto Function(Arguments... arguments) -> std::unique_ptr< Type >
R operator()(Args... args) const
Capture any invocable as a class, using std::function only when needed.
typename std::conditional_t< std::is_class_v< Invocable >, Invocable, FunctionInvoker< std::remove_pointer_t< Invocable > > > type
Capture pointer to member.
std::invoke_result_t< Member, T > Result
constexpr MemberInvoker(Member member)
auto operator()(Obj &&obj) const -> std::enable_if_t< CanAccept< Obj && >::value, Result< Obj && > >
constexpr OverloadSetBase(Is &&... invocables)
Variadic constructor allowing arguments with different value categories.
constexpr OverloadSetBase(const OverloadSetBase &)=default
constexpr OverloadSetBase()=default
constexpr OverloadSetBase(OverloadSetBase &&)=default
standard in C++20; add a level of indirection to a type