On 29 May 2013 12:29, Anders Logg <[email protected]> wrote: > On Wed, May 29, 2013 at 12:00:49PM +0100, Garth N. Wells wrote: >> The MeshFunction class has a lot of constructors. This roughly doubled >> recently with the switch to using shared pointers for the mesh (now >> ~10 constructors). >> >> What are the opinions on having duplicate reference/shared_ptr >> constructors in MeshFunction? Should we just have shared_ptr versions? >> This only affects the C++ interface. The Python interface uses the >> shared_ptr version (but does requires the other constructors being >> marked in the SWIG layer as to be ignored, which is easy to forget). > > I see the motivation (to reduce the number of duplicate constructors) > but I still think one should be able to write a simple C++ demo > program without using boost::shared_ptr. > > Is there some other solution? Could one add a cast function to the > Mesh class, something like this: > > operator boost::shared_ptr<Mesh>() > { return reference_to_no_delete_pointer(*this); } >
I wouldn't advocate this solution - the function signature would lead a user to believe that memory management is robust, and an opaque magic conversion layer would alter this. How about only having reference versions for the higher level constructors only, e.g. those that appear in demos. Garth > ? > > -- > Anders _______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
