utils: small_vector: add print operator for std::ostream

In order to replace std::vector with utils::small_vector, it needs to
support this feature too.
This commit is contained in:
Avi Kivity
2021-04-29 16:05:07 +03:00
parent 84ea06f15b
commit 3114f09d76

View File

@@ -468,4 +468,19 @@ public:
}
};
template <typename T, size_t N>
std::ostream& operator<<(std::ostream& os, const utils::small_vector<T, N>& v) {
os << "{";
bool first = true;
for (auto&& e : v) {
if (!first) {
os << ", ";
}
first = false;
os << e;
}
os << "}";
return os;
}
}