[Qt-interest] Const correctness with QSharedPointer

Brad Howes howes at ll.mit.edu
Mon Dec 7 21:42:29 CET 2009


On Dec 7, 2009, at 3:31 PM, Colin Kern wrote:

> I want to pass a QSharedPointer to a function as a const pointer, so
> that the compiler will enforce that I don't mutate the object the
> shared pointer is pointing to.  Can I do this with "void func(const
> QSharedPointer<A> p);" or does that just enforce that I won't change
> what the shared pointer is pointing to?


I usually use const QSharedPointer<A>& but your declaration is also correct.

Brad

-- 
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420








More information about the Qt-interest-old mailing list