ostream_iterator with map pairs
[Please do not mail me a copy of your followup]
I must be doing something wrong, but I expected this to compile and work:
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
std::ostream& operator<<(
std::ostream& out,
const std::pair<size_t, size_t>& rhs)
{
return out << rhs.first << ", " << rhs.second;
}
int main()
{
std::map<size_t, size_t> m;
for (size_t i = 0; i < 10; ++i)
{
m[i] = 2U*i;
}
std::copy(m.begin(), m.end(),
std::ostream_iterator<const std::pair<size_t, size_t>>(std::cout,
"\n"));
return 0;
}
....but I get a compile error where ostream_iterator is instantiated
both on g++ 4.6.3 and VS 2013.
What am I missing?
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]