View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0025444 | Community | OCCT:Foundation Classes | public | 2014-11-02 10:04 | 2017-08-14 17:18 |
Reporter | Roman Lygin | Assigned To | |||
Priority | normal | Severity | integration request | ||
Status | resolved | Resolution | open | ||
Product Version | 6.8.0 | ||||
Target Version | Unscheduled | ||||
Summary | 0025444: Enabling user-defined deleter for NCollection_Handle | ||||
Description | Until this enhancement NCollection_Handle would enforce deletion of the object passed to its constructor. However this must not be done in the scenario when the handle does not own but just wraps the object. Consider the following scenario: class MyType; //not manipulated by handle class MyTypeOwner { public: std::unique_ptr<MyType> myObject; }; std::vector<Handle_Standard_Transient> v; //holds OCC handles and need to store raw pointers MyType*. v.push_back (new Geom_Circle (...)); ... const MyTypeOwner& o = ...; NCollection_Handle<MyType> h (o.myObject.get()); v.push_back (h); //upon leaving the scope, v will nullify handles, each handle will attempt to delete MyType pointers although it does not own it The enhancement introduces user-defined deleters similar to what C++ standard smart pointers do. The current behavior is preserved by using NCollection_Handle_DefaultDelete as default template parameter. The above code can be now reworked as follows: NCollection_Handle<MyType,NCollection_Handle_EmptyDelete<MyType> > h (o.myObject.get()); Unlike C++ standard, deleters objects cannot be passed as constructor arguments. For simplicity they are always internally created and thus must meet DefaultConstructible requirement. If stronger standard compliance is required and deleters object are to be stored then implementation must foresee size optimization (e.g. as described here http://talesofcpp.fusionfenix.com/post-18/episode-ten-when-size-does-matter). | ||||
Tags | No tags attached. | ||||
Test case number | |||||
Date Modified | Username | Field | Change |
---|---|---|---|
2014-11-02 10:04 | Roman Lygin | New Issue | |
2014-11-02 10:04 | Roman Lygin | Assigned To | => abv |
2014-11-02 10:10 | git | Note Added: 0034002 | |
2014-11-02 10:12 | Roman Lygin | Status | new => resolved |
2014-11-05 09:15 |
|
Target Version | 6.8.0 => 7.0.0 |
2015-12-14 22:39 |
|
Target Version | 7.0.0 => 7.1.0 |
2016-11-03 17:07 |
|
Target Version | 7.1.0 => 7.2.0 |
2017-08-14 17:18 |
|
Target Version | 7.2.0 => Unscheduled |