Should I compare pointers with is of == ?

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 14 06:26:36 PDT 2009


On Wed, 14 Oct 2009 08:15:01 -0400, #ponce <aliloko at gmail.com> wrote:

> It's a bit unclear to me.
>
> I know I must compare references with is but pointers ?

Like Moritz said, there is no semantic difference with pointers, but you  
may consider comparing with is if you are looking for equivalence.  It  
cannot ever be overridden, so if for some reason you decided to change  
your pointer to a class reference, it doesn't accidentally morph into a  
virtual call (possibly to a null object causing a segfault).

-Steve


More information about the Digitalmars-d-learn mailing list