Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-10-04 11:26:13

From: "Gennadiy Rozental" <gennadiy.rozental_at_[hidden]>
> [From: Rob Stewart]
> > I think you misunderstood what Gennadiy meant. (If not, I think
> > this is a good idea, anyway.) Your function should accept an
> > output iterator through which you save the results. That enables
> > the caller to decide where the results go instead of you deciding
> > that they go into a list which then must be iterated. Thus, I'm
> > proposing something like this:
> >
> > template <typename OutIt, typename Char>
> > OutIt
> > glob(OutIt & out, std::basic_string<Char> const & pattern,
> > filesystem::path const & pathname, glob_flags flags);
> I don't think I ever suggested this. Plain iterator is what I meant. How

Sorry, I misunderstood you, then.

> would I iterate using above interface?

You wouldn't, of course. You'd use it to write to something
else, including std::cout.

> > Appropriate output iterators can forward the matches to a
> > collection, to a GUI control, to a file, etc.
> >
> > > It works, but is considerably slower than the function returning a list.
> No
> > > doubt profiling will help track down what I'm doing inefficiently.
> >
> > No doubt.
> I do not see anything in iterator implementation that suggest inherent
> inefficiency.

What he described sounded like he populated a container with the
results and then iterated that. Using the resulting iterator to
populate another container would, thus, reduce efficiency.

Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at