
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