fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. template <template <class> class pred, typename T = double>
  5. void apply(vector<vector<T>> & m, const T & rhs) {
  6. for (auto & i : m)
  7. for (auto & j : i)
  8. j = pred<T>()(j, rhs);
  9. }
  10.  
  11. int main() {
  12. vector<vector<double>> m(2, vector<double>(2));
  13. apply<minus>(m, 1.0);
  14.  
  15. for (auto & i : m)
  16. for (auto & j : i)
  17. cout << j << endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
-1
-1
-1
-1