Boost C++ Libraries: Ticket #7535: filesystem::path::iterator inconsistency with multiple leading separators https://svn.boost.org/trac10/ticket/7535 <p> Iterating backwards through a filesystem::path does not terminate at path::begin() if the path starts with several leading directory separators. </p> <p> For example: </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; #include &lt;iostream&gt; int main() { boost::filesystem::path p("/////foo"); boost::filesystem::path::iterator i = p.begin(); ++i; --i; std::cout &lt;&lt; ((i == p.begin()) ? "same" : "different") &lt;&lt; std::endl; } </pre><p> Expected output: <code>same</code> <br /> Actual output: <code>different</code> </p> <p> Looking at the source (filesystem/src/path.cpp), it seems that in path::begin() the iterator's m_pos member is set to the position of the last leading directory separator. </p> <p> During backward iteration, m_pos is set to 0, though, so the iterator comparison (which involves comparing the m_pos members) yields false. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7535 Trac 1.4.3