📜  c++ print vector without loop - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:47.185000             🧑  作者: Mango

代码示例1
template 
std::ostream& operator<< (std::ostream& out, const std::vector& v) {
  if ( !v.empty() ) {
    out << '[';
    std::copy (v.begin(), v.end(), std::ostream_iterator(out, ", "));
    out << "\b\b]";
  }
  return out;
}