[fpc-pascal] cloning data containers
iz.iznogood at gmail.com
Sat Dec 27 18:56:38 CET 2014
FPC does not support copy-construction so either you must override the
TPersistent.Assign method or in case of TComponent you can use
You should also take into account deep vs swallow copy semantics as well as
the type of the container and contained classes
For records I am not sure, probably you should need a method on the
container or check on some internal (compiler magic) functions such as
CopyRecord and others.
Hope that helps.
On Dec 27, 2014 6:22 PM, "Marc Santhoff" <M.Santhoff at web.de> wrote:
> On Sa, 2014-12-27 at 16:45 +0100, Bart wrote:
> > On 12/27/14, Marc Santhoff <M.Santhoff at web.de> wrote:
> > > function clone(data_in: a_record): a_record;
> > > var
> > > data: Pa_record;
> > > begin
> > > new(data);
> > data^ := data_in; //should work*
> > > end;
> > * Might not be a good idea if data contains a class(reference).
> Oops, I just typed that away and did not hit CTRL-F9 - which is useless
> in the mailer anyway. ;)
> Marc Santhoff <M.Santhoff at web.de>
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal