DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0024407

Extend Handle by implicit DownCast capabilities

Open CASCADEOCCT:Foundation Classesclosed1 public note

Search issues

Description

It could be useful to extend Handle types by additional constructor and assignment operator that would provide implicit DownCast capabilities, to do something like this:

Handle(Geom_Curve) aCurve = ...; // Get a curve from somewhere
Handle(Geom_Circle) aCircle1(aCurve); // Now it is impossible
Handle(Geom_Circle) aCircle2 = aCurve; // Now it is impossible

The new approach could help reduce the amount of code.

Public activity

1 archived note

Participants are labeled by their role within this record.

01Commenter 1
Implicit downcasting can be quite dangerous, requiring explicit call to method DownCast() makes this non-trivial action more explicit (and is consistent with common approach adopted in C++ standard library), thus closing