Advertisement
kalabukdima

reading vector

Jan 7th, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. template <class Is>
  2. std::vector<int> read(Is&& is) {
  3.     int n = 0;
  4.     is >> n;
  5.     std::vector<int> v(n);
  6.     for (auto& e : v) {
  7.         is >> e;
  8.     }
  9.     return v;
  10. }
  11.  
  12. void foo() {
  13.     const auto v = read(std::cin);
  14. //  const auto v = read(std::ifstream("input.txt"));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement