|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-10-18 01:26:34
Andrey Semashev wrote:
> > How would that work, exactly? Take the example function signature and
> > show us how it's done.
>
> boost::string_view get_string();
>
> template< typename String >
> String get_string()
> {
> boost::string_view res = get_string();
> return String(res.data(), res.size());
> }
The function is
boost::string_view api_function( boost::string_view str );
If we apply the technique above,
api_function( "something" );
will return boost::string_view, and C++17 users will have the option
of using
auto r = api_function<std::string_view>( "something" );
Again, this works, but isn't exactly optimal. C++17 users are penalized
for no good reason.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk