The second version of getChildFile() fail to compile. A const problem.
The whole thing is ReferenceCountedObjectPtrs. Is the right solution a ReferenceCountedObjectPtrConst, const_cast? Drop all the const qualifiers, even though it's basically const? I tried:
ReferenceCountedObjectPtr<const LibraryFile> just in case, but it gets into trouble in the template because a ReferenceCountedObject is not really const when it comes to the reference counting. Is that a valid use for mutable though really?
Herb Sutter did a good talk recently suggesting that we should start thinking about const/mutable in terms of thread-safety, i.e. it's ok for something to be marked const and use mutability internally if the function is thread-safe. So in the case of a ReferenceCountedObjectPtr, it would sort of be OK for it to take a const object because it should be thread-safe (since it uses atomics), even though it clearly mutates the object, and may even delete it.
Yeah. I felt like I was getting into some C++ language beard stroking moment. And now you mention Herb ... not that he's got much of a beard, but definitely involved in the stroking.
I might do a const_cast for the moment. I don't think I'm going to go to jail for it...given that we think it'd be reasonable for the only field that's changing to be mutable.