Boost logo

Boost :

From: dizzy (dizzy_at_[hidden])
Date: 2008-07-31 03:47:24


On Thursday 31 July 2008 03:10:24 Noah Roberts wrote:
> "Class basic_directory_iterator is an important component of the
> library. It provides an input iterator over the contents of a directory,
> with the value type being class basic_path."
>
> That seems to be correct.

It's not, in boost 1.34 (if I remember correctly)
boost::filesystem::directory_iterator has become an iterator to
directory_iterator_entry values rather than to path values as it was before.
Implicit conversion operator to path was added (along with an "explicit"
getter like .path()).

> "The expression itr->path().leaf() == file_name, in the line commented
> // see below, calls the leaf() function on the path returned by calling
> the path() function of the directory_entry object pointed to by the
> iterator."
>
> But that claims the object pointed to the iterator is something other
> than basic_path and appears to be quite in error. itr->path() fails to
> compile.

Exactly. See 1.34/1.35 docs, for example:
http://www.boost.org/doc/libs/1_34_1/libs/filesystem/doc/tr2_proposal.html#Class-template-basic_directory_iterator

It says: " The result of operator* on an end iterator is not defined. For any
other iterator value a const basic_directory_entry<Path>& is returned. The
result of operator-> on an end iterator is not defined. For any other
iterator value a const basic_directory_entry<Path>* is returned."

I do not know why itr->path() fails to compile on your system, maybe you are
using boost 1.33 or older.

> Documentation is same for both 1.34 and 1.35 - tested on 1.34.

Can you be more explicit (URLs?) where the 1.34/1.35 documentation says that
directory_iterator points to a path instead of a directory_iterator_entry?
Such statements need correction. Generaly I have used the "reference"
documentation for boost filesystem which I do not know to have such problems.

> This appears in both the front page and the docs for directory iterator.
> The find_file function doesn't actually compile if copied verbatim.
> Need to remove all calls to path() on the iter and replace with "*itr".

You have an older (than 1.34) boost version installed on your system if that
does not compile.

-- 
Mihai RUSU					Email: dizzy_at_[hidden]
			"Linux is obsolete" -- AST

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