
18 Oct
2021
18 Oct
'21
1:26 a.m.
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_functionstd::string_view( "something" ); Again, this works, but isn't exactly optimal. C++17 users are penalized for no good reason.