chore(cpp): add ‹<<› for containers

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-07-29 16:00:10 +02:00
parent f6e3929fee
commit e9a7fb0955
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -39,6 +39,17 @@ std::ostream &operator<<(std::ostream &os, std::pair<T, U> const &p) {
return os << p.first << " " << p.second; return os << p.first << " " << p.second;
} }
template <typename C, typename T = typename std::enable_if<
!std::is_same<C, std::string>::value,
typename C::value_type>::type>
std::ostream &operator<<(std::ostream &os, const C &v) {
std::string sep;
for (const T &x : v) {
os << sep << x, sep = " ";
}
return os;
}
template <typename T> template <typename T>
inline void answer(const T &ans) { inline void answer(const T &ans) {