shared_ptr and nullptr

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
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
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
1
2
//b->get()
b.get()
Last edited on
Topic archived. No new replies allowed.