------- Comment #18 from aburger at cea dot fr 2005-12-14 19:16 -------
This does not compile, and it is much simpler than ostr(ing)stream:
class A {
public:
int a;
A() : a(0) {}
A& operator<<(int aa) { return *this; }
};
A& operator<<(A& thys, A& (*f)(A&))
{ return f(thys); }
A& tic(A& a)
{ return a; }
int main()
{
A() << 12 << tic; // ok
A a; a << tic << 12; // ok
//A() << tic << 12; // does not compile:
#if 0
err.cxx:28: invalid conversion from 'A&(*)(A&)' to 'int'
err.cxx:28: initializing argument 1 of 'A& A::operator<<(int)'
#endif
}
#if 0
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)
#endif
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9925