Apr 16, 2012 at 2:23pm UTC
I have some function from third party library that i want to wrap, and sometimes i must pass nullptr.
Is this safe?
1 2 3 4 5 6 7 8 9
typedef std::shared_ptr<Bar> sp_Bar;
...
void foo(UINT inx, sp_Bar b)
{
device->setSomething( inx, b->get() );
}
...
foo(nullptr );
edit: I am using VS2010 (default stl lib)
Last edited on Apr 16, 2012 at 2:26pm UTC
Apr 16, 2012 at 2:54pm UTC
You pass one argument to a function taking two arguments and b->get()
should be b.get()
. Ignoring that, it's safe if setSomething can handle null pointers.
Last edited on Apr 16, 2012 at 2:56pm UTC
Apr 16, 2012 at 2:55pm UTC
Thanks.
If setSomething can handle null pointers it's safe.
Yes, it does some other thing if param is 0.
edit: Yes its a typo
Last edited on Apr 16, 2012 at 3:08pm UTC