Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2022-08-15 14:57:20


On 8/15/22 17:10, Vinnie Falco wrote:
> On Mon, Aug 15, 2022 at 3:37 AM Andrey Semashev via Boost
> <boost_at_[hidden]> wrote:
>> Could you describe why you need to construct/assign/append to paths from
>> arbitrary containers and why you cannot use string types or iterators?
>
> Yeah, and from your description it sounds like maybe it is just a user
> error on my part or a bug. The container in question is
> boost::urls::pct_encoded_view:
>
> <https://github.com/CPPAlliance/url/blob/cba301383791f67c31b3ccd52a401849f7cf8940/include/boost/url/pct_encoded_view.hpp#L75>
>
> This used to work:
>
> pct_encoded_view v;
> boost::filesystem::path p;
>
> p.append( v );
>
> What should happen here is that a path segment will be appended to p
> formed by applying percent-decoding to the string referenced by 'v'
> (the percent-decoding happens in the iterator).

With std::filesystem::path that is what would happen, though
pct_encoded_view::operator std::string(). With boost::filesystem::path,
it will construct the path from a string that is obtained from
[v.begin(), v.end()) range (which, I presume, will not be
percent-encoded). Since the recent change, it will also give you a
deprecated warning.

The correct code is either use v.to_string() or explicitly use
v.begin()/v.end(), depending on what you want.

BTW, duplicate "as a" here:

https://github.com/CPPAlliance/url/blob/cba301383791f67c31b3ccd52a401849f7cf8940/include/boost/url/pct_encoded_view.hpp#L57


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk