fork(1) download
  1. #include <complex>
  2. #include <functional>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using Complex = std::complex<double>;
  7.  
  8. using namespace std::literals::complex_literals;
  9.  
  10. struct S
  11. {
  12. std::vector<Complex> data;
  13. S& apply(std::function<Complex(Complex const&)> f)
  14. {
  15. for( auto& elem : data )
  16. {
  17. elem = f(elem);
  18. }
  19. return *this;
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25. S s{{1.i,-2.i,3.i}};
  26. s.apply(static_cast<Complex (*)(const Complex&)>(std::conj));
  27. return EXIT_SUCCESS;
  28. }
Success #stdin #stdout 0.01s 5488KB
stdin
Standard input is empty
stdout
Standard output is empty