Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-10-18 01:05:10


Andrey Semashev wrote:
> > Remember that libraries also need to return string_views.
>
> Yes. Depending on the case, this can be worked around too. For example,
> have a convention that if you accept a string_view, you return the same kind
> of string_view as well.

And now all code that used to pass string literals or std::strings is broken
because of ambiguity. And if you add overloads to fix the ambiguity
(remember that the whole purpose of string_view is to let you get by without
adding overloads), you can't return both string views at once.

> If you don't accept a string_view, let the user choose
> what he wants. Pick a default, if that's too verbose.

How would that work, exactly? Take the example function signature and
show us how it's done.


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