Answers for "c++ print vector without loop"

C++
1

c++ print vector without loop

template <typename T>
std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
  if ( !v.empty() ) {
    out << '[';
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
Posted by: Guest on August-19-2020

Browse Popular Code Answers by Language