url icon indicating copy to clipboard operation
url copied to clipboard

Get segments_view from url is not straightforward

Open alandefreitas opened this issue 3 years ago • 2 comments

Functions might require segments_view so that they work for url_view and url. A mutable url_view returns segments_view while a mutable url returns urls::segments.

This means the url needs to converted to const or to its base class url_view to access the segments_view.

Example:

bool my_function(urls::segments_view target, urls::segments_view prefix);

would require:

url_view uv = /* ... */;
url u = /* ... */;
my_function(
    uv.segments(),
    static_cast<urls::url_view>(u).segments());

alandefreitas avatar Aug 03 '22 00:08 alandefreitas

now that we no longer allocate, shouldn't they be freely convertible back and forth?

vinniefalco avatar Aug 03 '22 00:08 vinniefalco

I think so.

alandefreitas avatar Aug 03 '22 01:08 alandefreitas

This works:

url u( "/path/to/file.txt" );

segments_view ps( u.segments() );

so I think we're good now

vinniefalco avatar Sep 11 '22 23:09 vinniefalco