void f(boost::shared_ptr<int> ptr)
{
if (ptr) // should we check?
// do something
}
void f2(int *p)
{
if (p) // good practice to check before using it
// do something
}
質問:shared_ptr
を使用する前に検証する必要がありますか?boost :: shared_ptrまたはstd :: shared_ptrを使用する前にチェックする必要がありますか?
参照の数をチェックするのに** use_count **関数を使用するだけで、チェックすることはありません。 – softghost