It looks like the boost::shared_ptr may have been the driver for using a reference rather than a pointer. Can we just call pContextDepth->get() to pass the pointer? (that might not be suitable for some reason I'm overlooking)