marshaller << obj_list;
what interesting is that obj_list is an instance of type std::vector
The answer is "I don't know", because it depends on if the operator << is overloaded for the marshaller type for std::map<>.
The secret why "marshaller << obj_list;" works is that, the marshaller type has an overloaded operator << for std::vector
T &operator << (T &t, const vector
Here is an example with cout:
ostream &operator << (ostream &out, const vector
{
vector
for (; itr != avector.end(); ++itr)
{
out << (*itr);
}
}
int main(void)
{
vector
for (int i = 0; i < 10; i++)
{
stringstream str_stream;
str_stream << i;
str_vector.push_back(str_stream.str());
}
cout << str_vector;
}
The output is:
0123456789
So for this works with std::map<>, we need to overload << for std::map<>.
Finally, it turned out that there is no such an overload, unfortunately. So we have to do it for each pare in the map.
No comments:
Post a Comment