aboutsummaryrefslogtreecommitdiff
path: root/ProjectBrussel/Common/YCombinator.hpp
blob: b1d2350e13d5c07599c89c3cdd279960fd689c6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#pragma once

template <class Func>
struct YCombinator {
	// NOTE: implicit constructor allows initializing this
	Func func;

	template <class... 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)...);
	}
};