I created my own << overload for bool because I wanted it to print true and false instead of 1 and 0. This usually works, except when I leave the namespace in which I defined this operator. In that case I get an ambiguous operator error.
error C2593: 'operator <<' is ambiguous
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(206): could be 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\Dummy.h(43): or 'std::ostream &Dummy::operator <<(std::ostream &,bool)'
while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, bool)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
How do I specify which namespace to take the operator from? Naively I tried Dummy::<< and Dummy::operator<< but neither worked.
You should take a look at
std::boolalpha, but to answer your original question:output