Boost logo

Boost :

Subject: Re: [boost] Variadic append for std::string
From: Christof Donat (cd_at_[hidden])
Date: 2017-01-26 08:27:49


Hi,

Am 26.01.2017 10:47, schrieb Richard Hodges:
>> I don't see any particular reason why you can't provide all of them,
>> though (even the implicit conversion), as different things are going
>> to
>> feel more natural to different people, particularly in different
>> contexts.
>
> There's a problem with implicit conversion.
>
> imagine the overloads function:
>
> void foo(std::string const& s);
[...]
> foo(join(...));
[...]
> void foo(std::string_view s);
> void foo(const char* s);
>
> Now the above code will not compile, because there are 3 ambiguous
> overloads.

But that is only an issue for users, who have relied on the implicit
conversion upfront. You can always use an implicit conversion explicitly
as well, of course, and implicit conversion will be just one of multiple
options, if we add it.

> The moral of the story is that if we are going to provide conversion
> operators, they need to be explicit anyway.

Up to now, you haven't made a point here. Just those users, who decide
to rely on implicit conversion, instead of one of the explicit variants,
have to cope with the downsides of implicit conversion. Others don't. I
think that fits well with "don't pay for what you don't use".

> Template specialisations of free functions are always a bad idea - they
> don't play nicely with ADL. So I would not recommend
> convert<std::string>(join(...)) etc.

Please elaborate more on that. I can't see it.

Christof


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