View Issue Details

IDProjectCategoryView StatusLast Update
0025444CommunityOCCT:Foundation Classespublic2017-08-14 17:18
ReporterRoman Lygin Assigned Toabv  
PrioritynormalSeverityintegration request 
Status resolvedResolutionopen 
Product Version6.8.0 
Target VersionUnscheduled 
Summary0025444: Enabling user-defined deleter for NCollection_Handle
DescriptionUntil 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
    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
TagsNo tags attached.
Test case number



2014-11-02 10:10

administrator   ~0034002

Branch CR25444 has been created by Roman Lygin.

SHA-1: 9e18d3785e1c59a7f12f2f6f1a6819ecdd31eda8

Detailed log of new commits:

Author: Roman Lygin
Date: Sun Nov 2 10:10:36 2014 +0400

    0025444: Enabling user-defined deleter for NCollection_Handle

Issue History

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 abv Target Version 6.8.0 => 7.0.0
2015-12-14 22:39 abv Target Version 7.0.0 => 7.1.0
2016-11-03 17:07 abv Target Version 7.1.0 => 7.2.0
2017-08-14 17:18 abv Target Version 7.2.0 => Unscheduled