Rewrote Common::List iterator code to ensure const correctness is preserved.
We tried to implement the list iterators in a clever way, to reduce code duplication. But this is essentially impossible to do properly, sadly -- this is one of the places where the ugly drawbacks of C++ really show. As a consequence, our implementation had a bug which allowed one to convert any const_iterator to an iterator, thus allowing modifying elements of const lists. This rewrite reintroduces code duplication but at least ensures that no const list is written to accidentally. Also fix some places which incorrectly used iterator instead of const_iterator or (in the kyra code) accidentally wrote into a const list. svn-id: r39279
This commit is contained in:
parent
6c93249715
commit
5181546c63
9 changed files with 206 additions and 105 deletions
|
@ -507,7 +507,7 @@ bool ScummDebugger::Cmd_Debug(int argc, const char **argv) {
|
|||
// No parameters given: Print out a list of all channels and their status
|
||||
if (argc <= 1) {
|
||||
DebugPrintf("Available debug channels: ");
|
||||
for (Common::DebugChannelList::iterator i = lvls.begin(); i != lvls.end(); ++i) {
|
||||
for (Common::DebugChannelList::const_iterator i = lvls.begin(); i != lvls.end(); ++i) {
|
||||
DebugPrintf("%c%s - %s (%s)\n", i->enabled ? '+' : ' ',
|
||||
i->name.c_str(), i->description.c_str(),
|
||||
i->enabled ? "enabled" : "disabled");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue