Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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 << "]";
  }
  return out;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #print #vector #loop
ADD COMMENT
Topic
Name
7+4 =