
26 Sep
2011
26 Sep
'11
7:51 a.m.
Matheus Peschke de Azevedo wrote:
Krzysztof,
According to the C++ standard, the ostream output (cout and wcout) will only handle built-in types (e.g., int, char, double, etc).
Not true, vide ::std:: complex.
It's up to the developer implement how all other types will print to the output. See full rationale and details in Stroustrup, Bjarne TCPPPL 3rd Edition - 21.2.2 Output of Built In Types.
In short, you'll have to define a global operator<< for type std::pair
: template
std::basic_ostream<CharType>& operator<< (std::basic_ostream<CharType>& o, std::pair mypair) { return o << "This is my way of printing a pair: first: " << mypair.first << " and second: " << mypair.second; }
This is strictly forbidden by the standard AFAIK. Chris