Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- using namespace std;
- using namespace std::placeholders;
- bool check1(int a, int b) { return a + b > 0; }
- bool check2(int a, double b) { return a + b > 0; }
- bool check3(int a) { return a > 0; }
- struct AlwaysTrue {
- bool operator()(int i) const {
- return true;
- }
- };
- template <class FClass = AlwaysTrue>
- bool Foo(FClass foo = FClass()) {
- for (int i = 0; i < 3; ++i) {
- cout << foo(i) << " ";
- }
- cout << endl;
- }
- int main() {
- Foo(std::bind(check1, _1, 0));
- Foo(std::bind(check2, _1, .0));
- Foo(std::bind(check3, _1));
- Foo();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement