How to judge smart pointer "Handle" is null pointer

Hi Bros, I get some question when use the smart pointer "Handle" of OCCT.
As we know, in C++, judge null pointer can use “if(p==nullptr)”.

However, in OCCT it seems not work.
I can use "IsNull()" to judge some smart pointer like "Handle(TopoDS_Shape)", cause TopoDS_Shape has function "IsNull()";

but if I want to judge a smart pointer like:
”Handle(StepRepr_RepresentationItem) treader“
I don't know how to judge it a null pointer.

Artem Zhidkov's picture

Hi Linbei,

You may use "IsNull()" here the same way. The "Handle" object has its own "IsNull()" method, which only checks whether the pointer is initialized.

You could also use "if (p == nullptr)" for OCCT handles.

Regards,

Artem

linbei jianbaoxia's picture

Thanks, Artem. It works. I make mistakes. It works.
Bless you.