Is there a way to do complex copy from a map<A,B> to cout, use C++’s copy function ?
Seems complicated, since map has more than one item, and iterator itself doesn’t point to read data.
I mean something like what we do with vector:
copy (vector.begin(), vector.end(), ostream<int>(cout," "));
The value_type of a map is a
std::pair<key_type, assoc_type>. To do a copy, you need to provide anoperator<<that takes that type. For example, for amap<string, int>, it would be:You usually have to put that inside
namespace stdfor the compiler to find it though.