Subject: Re: [boost] boost::filesystem::path frustration
From: Neil Groves (neil_at_[hidden])
Date: 2013-01-25 20:05:52
> > I wonder if this is *really* what you want!
> A little credit, please. Yes, it's *really* what I want.
> Ah, please accept my apologies. You by default always have as much credit
as is humanly possible from me! I guessed that you might have wanted a
little more than you asked for. This was simply because I have made the
mistake of choosing the simpler requirement set when actually later I
realized I wanted the path processing. Sorry.
> > I suspect that you probably want to determine the common effective
> > prefix of the paths after canonicalisation.
> No, the paths are known to be already canonicalized (with a 'z' ;->)
I'll try and remember to use 'z'!
> > 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;
> >> std::cout << prefix << std::endl;
> > I think this code doesn't "work" because it meets the stated requirements
> > exactly! I think the requirements are normally greater than those we
> > think of when looking at the problem.
> A. you didn't know my requirements ;-), and
> True, but I would have felt bad if I had spotted a potential issue, stayed
silent and then found out that I could have saved you some time.
> B. for such an operation requiring the input paths to be canonical
> beforehand might in fact be the most appropriate interface.
> I can see an argument for that. I wasn't attempting to suggest that there
was one obvious correct idiom. I was really aiming to link to the previous
discussion and the supplied implementation for a solution. I think on most
observations I perceive similar improvements to be possible. My only real
disagreement is with labelling Boost.Filesystem as frustrating. For the
most part it helps me avoid writing tedious code. I like the idea of
improving the iteration scheme and making it more like a container.
> 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