diff --git a/doc/tutorial.html b/doc/tutorial.html index 72db485e..9520ab06 100644 --- a/doc/tutorial.html +++ b/doc/tutorial.html @@ -542,7 +542,7 @@ for (vec::const_iterator it (v.begin()); it != v.end(); ++it) { - cout << " " << *it << '\n'; + cout << " " << it->filename() << '\n'; } } @@ -565,28 +565,11 @@ -

The key difference between tut3.cpp and tut4.cpp is - what happens in the directory iteration loop. We changed:

-
-
cout << " " << *it << '\n';   // *it returns a directory_entry,
-
-

to:

-
-
path fn = it->path().filename();   // extract the filename from the path
-v.push_back(fn);                   // push into vector for later sorting
-
-

path() - is a directory_entry observer function. - filename() is one of +

filename() is one of several path decomposition functions. It extracts the filename portion ("index.html") from a path ("/home/beman/boost/trunk/index.html"). These decomposition functions are more fully explored in the Path iterators, observers, composition, decomposition and query portion of this tutorial.

-

The above was written as two lines of code for clarity. It could have - been written more concisely as:

-
-
v.push_back(it->path().filename()); // we only care about the filename
-

Here is the output from a test of tut4.cpp:

@@ -1127,4 +1110,4 @@ - \ No newline at end of file + diff --git a/example/tut4.cpp b/example/tut4.cpp index 5888c3ac..17c2ab04 100644 --- a/example/tut4.cpp +++ b/example/tut4.cpp @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) for (vec::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it) { - cout << " " << *it << '\n'; + cout << " " << it->filename() << '\n'; } } else