Handle vs SharedPointer #560
-
Hi, I would like to ask if I could use Shared Pointer from the C++ standard library instead of Handle? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The difference between OpenCascade's Key differences:
If you want to use OCCT effectively, it's better to stick with You can still use |
Beta Was this translation helpful? Give feedback.
The difference between OpenCascade's
Handle
and C++'sstd::shared_ptr
is similar to the difference betweenstd::shared_ptr
andboost::intrusive_ptr
.Key differences:
Intrusive vs. Non-intrusive Reference Counting:
Handle<T>
is intrusive - the reference count is stored in the object itselfstd::shared_ptr
is non-intrusive - the reference count is stored separately from the objectObject Requirements:
Handle<T>
requires objects to inherit fromStandard_Transient
std::shared_ptr
can wrap any objectMemory Layout:
Handle<T>
has less overhead since the reference count is inside the objectstd::shared_ptr
has more overhead (typically two pointers - one to the object and one to the co…