Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-09-01 03:24:53


Will Bryant wrote:

> I get a compiler error along the lines of
> "h:\libraries\boost\boost\test\utils\wrap_stringstream.hpp(66) : error
> C2679: binary '<<' : no operator found which takes a right-hand operand
> of type 'const std::basic_string<_Elem,_Traits,_Ax>' (or there is no
> acceptable conversion)" (with _Elem being wchar_t in this case, and
> _Traits and _Ax having the usual defaults).
......
> template <typename CharT, typename T>
> inline basic_wrap_stringstream<CharT>&
> operator<<( basic_wrap_stringstream<CharT>& targ, T const& t )
> {
> targ.stream() << t;
> return targ;
> }
........
>
> Since that backing ostringstream descends from ostream, I would have
> thought that all I needed to do was to ensure that there is a operator
> << (ostream&, wstring const&) defined, like this:
>
> ostream& operator << (ostream& ostr, wstring const& str)
> {
> ostr << "I'd put a wstring-to-string function here instead of
> this constant";
> return ostr;
> }

I think you need to define this in "namespace std". The

        targ.stream() << t;

code is inside operator<< in namespace boost. That operator hides all global
operators<< you might have. The only way your operator for wstring can be
found is via ADL, so you need to put it in namespace std.

- Volodya


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