cp-library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub Joe75792433/cp-library

:heavy_check_mark: cplib/vector_io.hpp

Verified with

Code

#pragma once

#include <cassert>
#include <iostream>
#include <vector>

namespace cplib {

template <typename T>
inline std::istream& operator>>(std::istream& is, std::vector<T>& v) {
#ifdef DEBUG
    assert(v.size() != 0);
#endif
    for (auto& x : v) is >> x;
    return is;
}

template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    const size_t len = v.size();
    for (size_t i = 0; i < len - 1; ++i) os << v[i] << ' ';
    if (len > 0) os << v[len - 1];
    return os;
}

}  // namespace cplib
#line 2 "cplib/vector_io.hpp"

#include <cassert>
#include <iostream>
#include <vector>

namespace cplib {

template <typename T>
inline std::istream& operator>>(std::istream& is, std::vector<T>& v) {
#ifdef DEBUG
    assert(v.size() != 0);
#endif
    for (auto& x : v) is >> x;
    return is;
}

template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    const size_t len = v.size();
    for (size_t i = 0; i < len - 1; ++i) os << v[i] << ' ';
    if (len > 0) os << v[len - 1];
    return os;
}

}  // namespace cplib
Back to top page