diff options
author | rtk0c <[email protected]> | 2022-05-30 15:56:29 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 15:56:29 -0700 |
commit | 80afa67d2b9f1c0605696a3fd69058544fe12fe4 (patch) | |
tree | 3dfe2a6f45e4f5ca8ad534baf06d76d9c558333b /source-common/YCombinator.hpp | |
parent | 0d92ecfdbfc875a099d9e83714b3a2209668fca5 (diff) | |
parent | 7d8bca09b3c4bf1418e758bd3bd0d6f85672153e (diff) |
Changeset: 53
Diffstat (limited to 'source-common/YCombinator.hpp')
-rw-r--r-- | source-common/YCombinator.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source-common/YCombinator.hpp b/source-common/YCombinator.hpp new file mode 100644 index 0000000..b1d2350 --- /dev/null +++ b/source-common/YCombinator.hpp @@ -0,0 +1,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)...); + } +}; |