#include <iosfwd>
struct foo { };
std::ostream &operator<< (std::ostream &out, const foo &) { return out; }
void format(std::ostream &out, const foo &x) { out << x; }
int main()
{
return 0;
}
Comeau online and g++ 4.6 both accept this code without issue. Visual C++ 2010 complains:
P:\guff>cl /nologo /EHsc /W3 ostream_fwd.cpp /Feostream_fwd.exe
ostream_fwd.cpp
ostream_fwd.cpp(7) : error C2027: use of undefined type 'std::basic_ostream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
Who's correct? If someone could try this on the latest Visual C++ compiler, I'd be interested to see what it says/does.