Skip to content

Instantly share code, notes, and snippets.

@dimka11
Created June 29, 2018 19:50
Show Gist options
  • Save dimka11/8772af382b6f9286aa2426b5d18164c5 to your computer and use it in GitHub Desktop.
Save dimka11/8772af382b6f9286aa2426b5d18164c5 to your computer and use it in GitHub Desktop.
Binder
#pragma once
class Max
{
public:
double operator()(double a, double b) {
return a >= b ? a : b;
}
};
template <class T, class F> class BinderTwoOne
{
F f;
T arg;
public:
BinderTwoOne(F _f, T _arg) :f(_f), t(_arg) {}
// вот в этом не уверен:
T operator()(F _f, T arg) {
return f(_f, arg);
}
};
void Run()
{
// из тетради:
max(x,5);
BinderTwoOne g (Max(),5);
g(10);
f(5)(6)
f.operator()(5)(6) // return function or functor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment