How to check a pointer from a function in C++ effectively and concisely?

  c++

if there any way to avoid this pattern (or be more concise) every time you get a pointer from a function (this happen a lot in my program):

type *p = Afunction();
assert (p != nullptr);
if ( p==nullptr )
{
    return;
}

because I don’t want my release software to crash if I receive a nullptr but also want to know when debuging if I encounter a nullptr

Source: Windows Questions C++

LEAVE A COMMENT