Boost logo

Boost :

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


Andrey Semashev wrote:
> Ok, let it be
>
> template< typename T >
> inline typename enable_if<
> is_same< T, std::string_view >,
> std::string_view
> >::type api_function( T str )
> {
> ...
> }

And now C++17 users are sad because when they call
the function with a literal or a std::string it returns a
boost::string_view, which they can't assign to a std::
string_view.

You'd probably have them use a conversion function
on each call. That's workable but does not exactly deliver
the best user experience.

No, the correct answer is that you write your own private
string_view and use that.

(Or tell your users to switch to C++23 I suppose.)


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