|
Boost : |
Subject: Re: [boost] boost::filesystem::path frustration
From: Dave Abrahams (dave_at_[hidden])
Date: 2013-01-27 19:55:50
on Sun Jan 27 2013, Eric Niebler <eniebler-AT-boost.org> wrote:
> On 1/25/2013 3:54 PM, Dave Abrahams wrote:
>>
>> on Fri Jan 25 2013, Eric Niebler <eniebler-AT-boost.org> wrote:
>>
>>> 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.
>>
>> Seriously, no. I have no problem using / for path construction, but
>> "divides" means division.
>
> struct append_path : std::divides<path> {};
> path prefix = std::accumulate( x.begin(), result.first, path(),
> append_path() );
That one's fine :-)
-- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk