[Insight-developers] Pointers vs Smart Pointers

Miller, James V (CRD) millerjv@crd.ge.com
Fri, 15 Dec 2000 15:59:36 -0500


The general rule of thumb is that function arguments are real pointers, not smart pointers.  If your
routine needs a persistent handle to the data, assign the real pointer to a smart pointer within your
code block.  The reason function take real pointers is to allow subclasses of the specified type to
be passed as well as the specified type.  Smart pointers will cast themselves back down to real
pointers when passed to a function, so a user can "send" a smart pointer to a function but the
function will receive the real pointer.



-----Original Message-----
From: Paul Hughett [mailto:hughett@mercur.uphs.upenn.edu]
Sent: Friday, December 15, 2000 2:39 PM
To: insight-developers@public.kitware.com
Subject: [Insight-developers] Pointers vs Smart Pointers



Are there any guidelines within the Insight project as to when to pass
arguments as plain pointers, smart pointers, or by value?  Is there
any tutorial explanation about using SmartPointers and the
ObjectFactory?  I'm having trouble synthesizing all the scattered
pieces of code into a coherent picture that tells me when and how to
use these mechanisms.

Paul Hughett

_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers