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 pointers destructor in the propagators 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:cschu...@kth.se Expert Researcher, SICS, cschu...@sics.se From: users-boun...@gecode.org [mailto:users-boun...@gecode.org] On Behalf Of Drescher, Conrad Sent: Friday, April 8, 2016 14:24 To: users@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 were not sure its 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.dresc...@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. _______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users