Boost logo

Boost :

From: Jordan DeLong (fracture_at_[hidden])
Date: 2005-05-31 22:26:18


First; pre-emptive apologies if this should be sent to boost-users
instead of here (or I guess the Mod can nuke it and tell me). I figured
I should send it here because it's more of a design issue than a "how
do I use this" issue...

path::begin() is defined as returning an 'iterator' (not a
const_iterator), so I figured I'd be able to write to it. I wrote some
code which did something like:

fs::path p;
/*...*/
for (fs::path::iterator it = p.begin();
        it != p.end();
        it++)
    if (*it == "FOO")
        *it = "BAR";

This errors because operator* on the iterator type returns a const
string&.

So: was this a deliberate design decision? I don't see anything about
this in the design rationale stuff in the docs for Boost.Filesystem.
Is there a good reason not to allow people to use the iterator to modify
individual path elements?

-- 
Jordan DeLong
fracture_at_[hidden]

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