Skip to content

Instantly share code, notes, and snippets.

@earl
Created July 7, 2009 17:21
Show Gist options
  • Save earl/142224 to your computer and use it in GitHub Desktop.
Save earl/142224 to your computer and use it in GitHub Desktop.
// 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