fork(1) download
  1. #include <iostream>
  2. #include <functional>
  3. #include <algorithm>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main() {
  8. using namespace std::placeholders;
  9. vector<double> dbl_vec {1.5, 2.5, 3.5, 4.5};
  10. for(const double &d : dbl_vec) cout << d << ' ';
  11. cout << endl;
  12. std::transform(begin(dbl_vec), end(dbl_vec), begin(dbl_vec), std::bind(::pow, _1, 2));
  13. for(const double &d : dbl_vec) cout << d << ' ';
  14. cout << endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1.5 2.5 3.5 4.5 
2.25 6.25 12.25 20.25