25 lines
576 B
C++
25 lines
576 B
C++
#pragma once
|
|
|
|
#include "util/utility.h"
|
|
|
|
template<typename... Ts>
|
|
struct overloaded : Ts... {
|
|
using Ts::operator()...;
|
|
};
|
|
|
|
template<typename... Ts>
|
|
overloaded(Ts...) -> overloaded<Ts...>;
|
|
|
|
template<typename Func, typename... BoundArgs>
|
|
auto partial(Func func, BoundArgs... bound_args) {
|
|
return [func, bound_args...](auto&&... call_args) {
|
|
return func(bound_args..., forward<decltype(call_args)>(call_args)...);
|
|
};
|
|
}
|
|
|
|
template<typename Type>
|
|
auto construct() {
|
|
return [](auto&&... args) {
|
|
return Type{forward<decltype(args)>(args)...};
|
|
};
|
|
}
|