url
url copied to clipboard
Get segments_view from url is not straightforward
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());
now that we no longer allocate, shouldn't they be freely convertible back and forth?
I think so.
This works:
url u( "/path/to/file.txt" );
segments_view ps( u.segments() );
so I think we're good now