fork download
  1. #include <iostream>
  2. #include <deque>
  3.  
  4. using namespace std;
  5. struct point_d
  6. {
  7. double x;
  8. double y;
  9. };
  10.  
  11.  
  12. struct point_f
  13. {
  14. float x;
  15. float y;
  16. };
  17.  
  18.  
  19. template<typename T>
  20. void save_to_file(deque<T> points, const string filename)
  21. {
  22. for (const auto & el : points) {
  23. std::cout << "{" << el.x << ", " << el.y << "}" << std::endl;
  24. }
  25. }
  26. int main() {
  27. deque<point_f> f = {{1,2}};
  28.  
  29. save_to_file<point_f>(f, "test");
  30.  
  31. deque<point_d> d = {{1,2}};
  32.  
  33. save_to_file<point_d>(d, "test");
  34. return 0;
  35. }
Success #stdin #stdout 0s 4520KB
stdin
Standard input is empty
stdout
{1, 2}
{1, 2}