Created
July 7, 2009 17:21
-
-
Save earl/142224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see http://earl.strain.at/space/2009-07-06 | |
#include <functional> | |
template <typename F, typename G, typename H> | |
struct compose3_t : public std::binary_function<typename G::argument_type, | |
typename H::argument_type, | |
typename F::result_type> { | |
F f; | |
G g; | |
H h; | |
compose3_t(const F &f, const G &g, const H &h): f(f), g(g), h(h) {} | |
typename F::result_type operator()(const typename G::argument_type &x, | |
const typename H::argument_type &y) const { | |
return f(g(x), h(y)); | |
} | |
}; | |
template <typename F, typename G, typename H> | |
compose3_t<F, G, H> compose3(const F &f, const G &g, const H &h) { | |
return compose3_t<F, G, H>(f, g, h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment