[webkit-dev] NeverNull<T>

Peter Kasting pkasting at google.com
Tue Jul 28 16:33:34 PDT 2009


On Tue, Jul 28, 2009 at 4:29 PM, Jozwiak, John <jjozwiak at qualcomm.com>wrote:

> Isn't the C++ "reference" annotation
>
>  char & x;
>
> tantamount to declaration of a pointer
>
>  char * x;
>
> to whom NULL assignment, as detectable at compile time, is a compile-time
> error?


Remember that you can't "reassign" a reference like you can a pointer
(though you can naively write code to do it, and it will compile, but it
won't do what you want).  This rules out the use of references in some
situations.

References are also more "subtle" in that you can write code that changes
things when it's not so obvious what's changing as when you use pointers.
 This is the primary reason that for example the Google style guide bans the
use of non-const references.

PK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090728/1f6c6dcd/attachment.html>


More information about the webkit-dev mailing list