|
Boost : |
From: Thomas Witt (witt_at_[hidden])
Date: 2002-09-16 04:13:07
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dave,
On Sunday 15 September 2002 13:44, David Abrahams wrote:
> From: "Thomas Witt" <witt_at_[hidden]>
>
> Why not just store it in the policies object to begin with, and provide an
> object factory (which takes a path) as many of the examples do?
>
> make_directory_iterator(char const* path)
> {
> dir_it(some_base_object(), dir_it_policies(path));
> }
>
Because it's the right solution at the wrong place? Seriously I do think that
using a object factory would just add overhead and provide zero benefit.
Iterator factories are cool if the iterator type is an complex template
expression that depends on the argument types and the user isn't really
interested in the type. They can save a lot of error prone typing. Like in
std::for_each(make_transform_iterator(it, AFunctor(),
make_transform_iterator(itEnd, AFunctor(), ....);
This point is moot with directory_iterator as its type(typedef) is simple and
known.
For directory iterator the factory function just adds typing.
std::for_each(make_directory_iterator(path),
make_directory_iterator(), ....);
opposed to
std::for_each(directory_iterator(path),
directory_iterator(), ....);
- -> no benefit.
for(directory_iterator it(make_directory_iterator(path)),
itEnd();
it != itEnd;
++it);
opposed to
for(directory_iterator it(path),
itEnd();
it != itEnd;
++it);
- -> the solution directly using ctor is shorter and less cluttered.
- --Thomas
- --
Dipl.-Ing. Thomas Witt
Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet Hannover
voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001
http://www.ive.uni-hannover.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9haCn0ds/gS3XsBoRAjPsAJ0fKpGW5sVU++tpHbG6L2T6VEXUvQCdGrz0
ZR8lGypnISDrgJfHA9Df278=
=0KlN
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk