Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-29 16:30:04


AMDG

Olaf Peter wrote:
> Anyway, overloading global operator<<() as
>
> template<typename T>
> static inline
> std::ostream& operator<<( std::ostream& os, const T& rhs )
> {
> return rhs.write_on( os );
> }
>
> would force all to have a write_on member function, isn't it. Is there a
> way around and even use operator<<() notation ??
>

I'm not sure I understand what you're trying to achieve. If you only
want the overload to be found for formatters, say

template<typename T>
inline std::ostream& operator<<( std::ostream& os, const formatter<T>& rhs )
{
    return rhs.write_on( os );
}

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net