Boost logo

Boost :

From: Walter Landry (wlandry_at_[hidden])
Date: 2003-11-11 20:11:08


Martin Wille <mw8329_at_[hidden]> wrote:
> Fredrik Blomqvist wrote:
>
> > David Abrahams wrote:
> >
> >>Walter Landry <wlandry_at_[hidden]> writes:
> >>
> >
> > [snip]
> >
> >>>I can't run std::sort() on those iterators.
> >>
> >> std::vector<path> v;
> >> std::copy(directory_iterator(p), directory_iterator(),
> >
> > back_inserter(v));
> >
> >> std::sort(v.begin(), v.end());
> >
> >
> > or even shorter:
> > std::vector<path> v(directory_iterator(p), directory_iterator());
>
> That would declare v as a function that returns a path.
> You'd have to add () around one of the arguments to make
> v a vector that is constructed by the two-iterator constructor.

That is a mostly perfect solution for me. I retract my original
suggestion. Its only disadvantage is that these vectors don't carry
around what path they were constructed from. On the other hand, it is
more flexible, because it can be generalized to any kind of container.

Regards,
Walter Landry
wlandry_at_[hidden]


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