blob: 2da06c83aa1a74c91666338750b834c8dc92f2f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#pragma once
template <typename Func>
struct YCombinator {
// NOTE: implicit constructor allows initializing this
Func func;
template <typename... Ts>
decltype(auto) operator()(Ts&&... args) const {
// NOTE: static_cast<Ts>(args)... is equivalent to std::forward<Ts>(args)...
// written this way so that we don't have to include <utility>, as well as reducing template instanciations to help compile time
return func(*this, static_cast<Ts>(args)...);
}
};
|