diff options
author | rtk0c <[email protected]> | 2023-09-20 23:58:58 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2023-09-20 23:58:58 -0700 |
commit | f138311d2d2e0cc9ba0496d523bb46f2c1c9fb73 (patch) | |
tree | f96100a813a4ffb28dcd074455d3a2f8ee426430 /source/10-common/YCombinator.hpp |
Copy from the PlasticSCM repo, replace vendored glm wtih conan
Diffstat (limited to 'source/10-common/YCombinator.hpp')
-rw-r--r-- | source/10-common/YCombinator.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/10-common/YCombinator.hpp b/source/10-common/YCombinator.hpp new file mode 100644 index 0000000..2da06c8 --- /dev/null +++ b/source/10-common/YCombinator.hpp @@ -0,0 +1,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)...); + } +}; |