As usual, bit of an odd one (though really, requests are only ever for odd things, as you think of everything!)
SHORT VERSION: would it be possible to add functionality for a MemoryBlock to not own it’s data? It would likely require a flag, but one which is not ever available for misuse; a MemoryBlock could return a const MemoryBlock object which describes a subset of the data it contains.
WHY: I’m making an app which communicates with other software, so naturally there are messages being passed about. When I recieve a message (in a memory block), I process the header to decide what to do next, and then I’d like to pass on what’s left of the message elsewhere for handling. I’d like to trim the header off, but as it stands I have to either (1) drop to void* and size parameter passing, or (2) make an unnecessary copy to a new memory block. What I’d like to do is say myBlock.getSubBlock(offset,size) [where size could be -1 to use the remaining data], and be given a const object I can pass to functions whilst i’m still within the lifetime of the source block.
Does this sound reasonable?