I use about 6 different C++ containers. I started writing print functions to output the container contents. Is this necessary? I would think this is part of the C++ library?<
It's not part of the library, but its easy to write with the tools provided:
C c; // Where C is a container type
std::copy(
c.begin(), c.end()
, std::ostream_iterator< C::value_type >( cout, " " )
);
For containers whose element is a pair
(like map
and I'd believe unordered_map
) you'd need a custom Output Iterator to print the pair
with the comma and brackets.