Boost logo

Boost :

Subject: [boost] [proto] Problems with operator <<
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-08-24 14:07:40


Folks,

I'm having no end of problems with operator<< and proto.

In the beginning, operator << was overloaded for stream output and
everything worked OK, then I added the left shift operator<< to the list of
protoized operators in the grammar and everything broke. The strange thing
is that:

std::cout << a+b;

correctly finds my stream out overload:

template <class Exp>
inline std::ostream& operator << (std::ostream& os, const
big_number_exp<Exp>& r)

But

std::cout << a;

no longer calls:

template <class Backend>
inline std::ostream& operator << (std::ostream& os, const
big_number<Backend>& r)

But calls the proto << operator instead.

I'm at a complete loss to explain this, both of my overloads are in the same
namespace as their respective types, and as far as I can see both should be
preferred to the proto versions.

Before I start tearing my hair out, anyone any ideas?

Thanks, John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk