News for hackers. Stuff that matters.
Re:More Dirty Coding Tricks from Game Developers (2010) by golergka on Monday August 03, 2015 @05:12AM (#9994593)
Thanks! Your first two answers would be obvious if we assume that we're working with modern codebase written by adequate developers, but that's a very strong assumption to make, so I wanted to be specific.

And your final answer is, well, exactly the point I was trying to steer the conversation to. In other words, if you declare both methods, it means that you're doing something wrong: you're giving away data mutably and immutably at the same time, and it just doesn't make sense.

Re:More Dirty Coding Tricks from Game Developers (2010) by SamReidHughes on Monday August 03, 2015 @05:16AM (#9994609)
You aren't.

If you have a non-const node, you can access its children non-constly _or_ constly (which you could do anyway, since you could make your reference to the node be const at any time). If you have a const node, you can only access its children constly.

This makes perfect sense.

Re:More Dirty Coding Tricks from Game Developers (2010) by golergka on Monday August 03, 2015 @05:57AM (#9994747)
My bad: didn't read the code carefully, thought that these were methods.
Re:More Dirty Coding Tricks from Game Developers (2010) by SamReidHughes on Monday August 03, 2015 @05:45AM (#9994703)
> if we assume that we're working with modern codebase written by adequate developers

Yeah, come to think of it if there's a chance this function came from a pre-C++11 codebase I wouldn't be so sure that the caller wasn't supposed to delete those nodes. Well, it'd be an odd thing for this particular function, I guess, but it's something I've seen or might have done, in general. In that case maybe I'd have had the function take an output parameter instead, in order to give it a scary variable name.