Uses for passing RefPtr as const&



In some cases when a signal handler takes a RefPtr const&, it only ever needs to observe the object, so it would seem simpler to pass a normal const& reference. What's the normal reason for passing a RefPtr const&?

To me it would express 'This thing is reference counted, and you can add a reference if you want, but I'm not going to make you (i.e. waste an increment/decrement just for every call)'. However, this doesn't always seem to be the case, as in a number of handlers I've seen, there appears to be no reason that the callee would take a reference.

Sorry if this is a silly question, but it popped into my head, so I thought I'd better write it down...


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]