Re: How to make a unique copy in a generic manner?

2012-07-16 Thread Jacob Carlborg
On 2012-07-16 20:48, Tommi wrote: How do you make a (deep) copy of a variable of any type? One way would be to serialize a value and the deserialize it. Although that would not be very efficient. https://github.com/jacob-carlborg/orange -- /Jacob Carlborg

How to make a unique copy in a generic manner?

2012-07-16 Thread Tommi
How do you make a (deep) copy of a variable of any type? For example the following attempt at a generic next function doesn't work, because it modifies its argument if the argument is a reference type. T next(T)(in T value) if (is(typeof(++[T.init][0]) == T)) { auto copy = cast(T) valu