'Stl way to fill vector instead /out.clear();out.reserve(n);loop{out.p_b(el.foo)}/

Is there a func in std to fill out with the same meaning?

template <class T> struct S {
  template <class U> void f(std::vector<U> &out) {
    out.clear();
    out.reserve(v_.size());
    for (const auto &el : v_) {
      out.push_back(el.foo);
    }
  }
  std::vector<T> v_;
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source