[webkit-dev] NeverNull<T>

Eric Seidel eric at webkit.org
Tue Jul 28 15:25:59 PDT 2009


It just occurred to me that we have a lot of places in WebKit were we
ASSERT(foo) (where foo is some passed in Foo* pointer which should never be
NULL).
Maybe it would be cleaner/better/whatever if we instead used a template to
do this ASSERTing in a centralized place.  The primary advantage would be
that the ASSERTion is clear in the method signature.

void doSomething(Foo* foo)
{
    ASSERT(foo);
}

becomes:

void doSomething(NeverNull<Foo> foo)
{
}

Could get nasty when interacting with other templates though.  I don't think
we want a NeverNullOwnPtr, or maybe we do?

Does this seem useful to anyone else?  Oh c++ experts, does this even seem
possible, seem like it would perform well, not bloat the code size, etc?

-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090728/64115d70/attachment.html>


More information about the webkit-dev mailing list