Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. #define W cout <<
  6.  
  7. template <class T>
  8. struct Dyn
  9. {
  10.     T (*f)(int x);
  11.     Dyn (auto _f) { f = _f; }
  12.     T operator [] (int x) { return f(x); }
  13. };
  14.  
  15. int main()
  16. {
  17.     Dyn<int> mul2( [](int x){return 2*x;} );
  18.     W mul2[2] endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement