Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- #define W cout <<
- template <class T>
- struct Dyn
- {
- T (*f)(int x);
- Dyn (auto _f) { f = _f; }
- T operator [] (int x) { return f(x); }
- };
- int main()
- {
- Dyn<int> mul2( [](int x){return 2*x;} );
- W mul2[2] endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement