On 05/30/2013 03:02 PM, Joseph Rushton Wakeling wrote:

> I would never have thought of that trick with the second template parameter.

Phobos is a source of ideas. ;)

> I guess it might fall over with complex structs or classes, though. :-\

Copying structs is trivial because they already have copy semantics:

    T b = a;  // b is a copy of a

However, that depends on correctly implemented copy semantics on T.

For classes, there is no syntax for copying. The type may have annotated a member function that it is the duplication function or we may know by convention that dup() is the equivalent of array .dup.

> What do you reckon the impact of this will be performance-wise?

As long there is no extra copy generated during the process, it should be fine. However, the usual issues around the current conservative GC applies. :/

Ali

Reply via email to