Boost logo

Boost :

Subject: [boost] [Filesystem V3] path and ostream
From: Juraj Ivanèiæ (juraj.ivancic_at_[hidden])
Date: 2011-03-07 10:10:57


During the switch from Filesystem V2 to V3 I was bit
by the new operator<<( basic_ostream<...> ) behaviour.
The problem is that in V3 the path gets quoted when
being output to the stream (and '&' is used as an
escape character). This breaks the invariant which
used to hold until now:

std::stringstream stream;
stream << path;
assert( stream.str() == path.string() );

I have made the adjustments to my code, but I find
this behaviour a bit surprising and was interested in
the rationale for this decision. I could not find it
on the Boost Filesystem home page.

The only reason I could fathom is so that one can do
this:

std::stringstream stream;
stream << path1 << path2;
stream >> path3 >> path4;
assert( path1 == path3 );
assert( path2 == path4 );

If so - I know several platforms where this will
generally fail, as both & and " are legal characters
in file names.

Thank you for your response.


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