On Mon, Jan 26, 2015 at 03:44:35PM +0100, Ingo Weinhold wrote: > On 01/26/2015 10:51 AM, pulkomandy@xxxxxxxxxxxxx wrote: > >############################################################################ > > > >Revision: hrev48723 > >Commit: e9b82428687037c1998e7140661a249710dd93c8 > >URL: http://cgit.haiku-os.org/haiku/commit/?id=e9b824286870 > >Author: Adrien Destugues <pulkomandy@xxxxxxxxx> > >Date: Thu Jan 22 13:36:40 2015 UTC > > > >Add a BConstReference class. > > > >This is a BReference that allows only const access to the referenced > >object. This was not easily possible with the existing BReference for > >two reasons: > >* BReference<const Type> would not work, as BReference needs to change > >the reference count of the referenced object. Adding mutable and casting > >where appropriate wouldwork but, > > Why not provide a specialization for const types instead? It would save the > additional class and avoid the fairly ugly implementation. I can't see what's the better way to do it, maybe I've been looking at my own code for too long. BReference<const Type> can't work because it cannot AcquireReference or ReleaseReference (these mutate the referenced object), unless the const is actually ignored by the BReference implementation (by casting it away), or AcquireReference/ReleaseReference declared const, and the fReferenceCount mutable, but I'm not sure this is a good way to handle this. Do you have another solution? -- Adrien.