[C++-sig] How about class_<...>.enable_copy() ?

Hans Meine meine at informatik.uni-hamburg.de
Fri Jun 8 17:06:36 CEST 2007


I often use copy.[deep]copy() to copy python objects / BPL-exported types.  
This works if pickling support has been explicitly coded, by pickling and 
unpickling.  It would be neat if there was an .enable_copy() or sth. like 
that, which would define a __copy__ (or __deepcopy__) method that simply 
calls the copy constructor.  That would be more efficient than the pickling 
approach, both at runtime and in terms of saved LOCs.  Have you thought about 
such a thing?  Is there a common short idiom that does that already?  Is 
there a rationale for not providing copying support?

Ciao, /  /
    /  / ANS

More information about the Cplusplus-sig mailing list