[gecode-users] Smart pointer in propagator?

Christian Schulte cschulte at kth.se
Tue Apr 12 21:21:50 CEST 2016


Hi Conrad,

There is a catch here: storing a smart pointer (or any other data structure
that has a destructor) in an object is okay, provided that:
1. You register the propagator so that its dispose() member function is
called when the propagator is deleted. But that you say you do.
2. You add an explicit call to the smart pointer’s destructor in the
propagator’s dispose() function, for example: if p is the smart pointer of
say type unique_ptr<T>, then add p.¨unique_ptr<T>() to the dispose() member
function.

That should do the trick. Is this worth being added as a tip to MPG?

Cheers
Christian

--
Christian Schulte, http://www.gecode.org/~schulte
Professor of Computer Science, KTH, mailto:cschulte at kth.se
Expert Researcher, SICS, cschulte at sics.se

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Drescher, Conrad
Sent: Friday, April 8, 2016 14:24
To: users at gecode.org
Subject: [gecode-users] Smart pointer in propagator?

Hi there,

we were thinking of storing a smart pointer in a propagator that is asking
its home space to call its dispose()-method upon home space deletion. In the
absence of a virtual destructor for class Propagator we’re not sure it’s a
smart idea. Reading MPG 30.2 did not entirely clarify the situation – could
you please elaborate?

Many thanks!
Conrad

Dr. Conrad Drescher
Senior Developer | AI DEV SCM PLM DE
SAP SE | Dietmar-Hopp-Allee 16 | 69190 Walldorf | Germany
T +49 6227 7-77888 | M +49 160 90684883 | E mailto:conrad.drescher at sap.com
http://www.sap.com/

Please consider the impact on the environment before printing this e-mail.


Pflichtangaben/Mandatory Disclosure Statements: 
http://www.sap.com/company/legal/impressum.epx

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine
Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt. Bitte
benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen
Dank. 

This e-mail may contain trade secrets or privileged, undisclosed, or
otherwise confidential information. If you have received this e-mail in
error, you are hereby notified that any review, copying, or distribution of
it is strictly prohibited. Please inform us immediately and destroy the
original transmittal. Thank you for your cooperation.





More information about the users mailing list