url icon indicating copy to clipboard operation
url copied to clipboard

The method `string` is surprising since it does not return a string

Open madmongo1 opened this issue 3 years ago • 0 comments

Before reading the documentation, it seemed obvious to me that in the following code:

auto
as_string(boost::urls::url_view uv)
{
  return uv.string();
}

Would return a string. In fact it returns a string_view, which may well actually be a dangling reference.

It seems to me that this is likely to be the source of many future support calls by surprised library users.

Proposal:

Provide both url[_view]::string() which returns a std::string, and url[_view]::string_view() which returns a std::string_view.

madmongo1 avatar Aug 13 '22 17:08 madmongo1