Boost C++ Libraries: Ticket #6778: directory_iterator and recursive_directory_iterator has inconsistent behavior with STL iterator when assignment operator=() is involved. https://svn.boost.org/trac10/ticket/6778 <p> For example, in std::vector, the following code shows that *vIterator_1 prints out intVec<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> and *vIteraotr_2 prints out intVec<a class="missing changeset" title="No changeset 0 in the repository">[0]</a>. (The assignment operator=() does not make those two iterators link together...) </p> <pre class="wiki">std::vector&lt;int&gt; intVec(10); intVec[1] = 1; std::vector&lt;int&gt;::iterator vIterator_1 = intVec.begin(); // iterator assignment operator=() now get involved. std::vector&lt;int&gt;::iterator vIterator_2 = vIterator_1; ++vIterator_1; // vIterator_2 does not increment. std::cout &lt;&lt; "*vIterator_1: " &lt;&lt; *vIterator_1; std::cout &lt;&lt; "*vIterator_2: " &lt;&lt; *vIterator_2; </pre><p> On the other hand, the following example shows that dirIterator1-&gt;path() and dirIterator2-&gt;path() both contains '/home/user/test/2.txt' which is not consistent with STL iterator behavior. Since iterators behaves like pointers, after calling vIterator_2 = vIterator_1;, vIterator_2 and vIterator_1 should stays independent. The problem seems to be directory_iterator forgot to implement the copy constructor and assignment operator=(). </p> <pre class="wiki">// assuming that under /home/user/test, there are 1.txt and 2.txt boost::filesystem::path rootPath("/home/user/test"); boost::filesystem::directory_iterator dirIterator1(rootPath); // Now assignment operator=() got involved. boost::filesystem::directory_iterator dirIterator2 = dirIterator1; // This line causes dirIterator1 and dirIterator2 both got incremented ... ++dirIterator1; std::cout &lt;&lt; "dirItertor1: " &lt;&lt; dirIterator1-&gt;path().string() &lt;&lt; std::endl; std::cout &lt;&lt; "dirItertor2: " &lt;&lt; dirIterator2-&gt;path().string() &lt;&lt; std::endl; </pre><h2 class="section" id="Note">Note</h2> <p> The symptom occurred in: </p> <p> boost::filesystem::directory_iterator<br /> boost::filesystem2::directory_iterator<br /> boost::filesystem3::directory_iterator<br /> boost::filesystem::recursive_directory_iterator<br /> boost::filesystem2::recursive_directory_iterator<br /> boost::filesystem3::recursive_directory_iterator<br /> </p> <p> under all platforms. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6778 Trac 1.4.3