Created
June 29, 2018 19:50
-
-
Save dimka11/8772af382b6f9286aa2426b5d18164c5 to your computer and use it in GitHub Desktop.
Binder
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
#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