Boost logo

Boost :

Subject: Re: [boost] boost::filesystem::path frustration
From: Eric Niebler (eniebler_at_[hidden])
Date: 2013-01-25 14:53:42


On 01/25/2013 08:30 AM, Beman Dawes wrote:
> Not particularly elegant, but this does work:
>
> path x("/foo/bar");
> path y("/foo/baar");
>
> auto result = std::mismatch(x.begin(), x.end(), y.begin());
>
> path prefix;
> for (auto itr = x.begin(); itr != result.first; ++itr)
> prefix /= *itr;

I believe this last bit is just std::accumulate with std::divides<path>.
Whether that better expresses intent is another matter.

Eric


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