Home » U++ Library support » U++ Core » Value: no deep copy support?
Re: Value: no deep copy support? [message #29440 is a reply to message #29438] |
Wed, 20 October 2010 16:55   |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
back to the topic:
offering a somehow optional way to be able to deepcopy the content of a Value would make it an appealing refcount based container for polymorphic stuff as well. Array<T> still needs some info about type.
Value doesnt.
i dont mean copy-on-write or something, which would be implicit, so the user does not get an idea of behaviour. he still can expect Value to be one (of many) references to the content.
but wanting to internally clone it without knowing type or anything about it would be great as well. enabling the user to 'edit' later 2 distinct copies in an abstract handler.
it could maybe rely on DeepCopyNew somehow. but this might need to introduce a Copy function in the Value::Void interface, returning Void*.
virtual Void* Copy() const { return new Void(); }
the RawValueRep<T> would add sth like:
virtual RawValueRep* Copy() const { return new RawValueRep(*this); }
//the value could then be MoveableAndDeepCopyOption
Value(const Value& v, int)
{
ptr = v.ptr->Copy();
//ptr->Retain(); //we are first owner
}
this would enable the approach described above
Value v = (int)123;
Value v2(v,0); //indicate to use the deep copy to duplicate the values
//v and v2 are now unrelated anymore..can be edited/overwritten individually
//using const_cast..clone has been produced without knowing content type.
Value v3;
vs <<= v; //same as with constructor, more intuitive, as from Containers :)
these are only very basic ideas, maybe it is of interest. i'll try to play with it a bit..maybe i can find sth usefull.
[Updated on: Wed, 20 October 2010 17:29] Report message to a moderator
|
|
|
 |
|
Value: no deep copy support?
By: kohait00 on Thu, 02 September 2010 15:58
|
 |
|
Re: Value: no deep copy support?
By: mirek on Mon, 06 September 2010 10:38
|
 |
|
Re: Value: no deep copy support?
By: mirek on Mon, 06 September 2010 10:39
|
 |
|
Re: Value: no deep copy support?
By: kohait00 on Wed, 20 October 2010 16:08
|
 |
|
Re: Value: no deep copy support?
By: kohait00 on Wed, 20 October 2010 16:55
|
 |
|
Re: Value: no deep copy support?
By: mirek on Wed, 20 October 2010 23:16
|
 |
|
Re: Value: no deep copy support?
By: kohait00 on Thu, 21 October 2010 08:47
|
 |
|
Re: Value: no deep copy support?
By: mirek on Thu, 21 October 2010 19:06
|
 |
|
Re: Value: no deep copy support?
By: kohait00 on Thu, 21 October 2010 20:17
|
 |
|
Re: Value: no deep copy support?
By: mirek on Thu, 21 October 2010 23:23
|
 |
|
Re: Value: no deep copy support?
By: kohait00 on Thu, 21 October 2010 23:30
|
Goto Forum:
Current Time: Mon Aug 25 12:39:08 CEST 2025
Total time taken to generate the page: 0.05944 seconds
|