Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.String.Convert
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-18 17:16:55

Emil Dotchevski wrote:

>> And what if I write my own class outer_bar that owns bar and also want to be
>> ostreamable? I would have to duplicate my operator<< in order to call either
>> to_string or to_wstring, wouldn't I?
> No.
> You can define template operator<<

How is that?

> or you can define non-template
> std::string overload of operator<< only. The user would still be able
> to call to_wstring, which will bind to a wstring overload if it's
> available. If not, the generic to_wstring overload will call the
> std::string operator<< overload, and then convert the result to
> wstring.

But I will lose generic ostreamability for my class then. Sorry, I just
don't see any advantages for differently named functions.

Boost list run by bdawes at, gregod at, cpdaniel at, john at