Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
kohait00 is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PolyDeepCopyNew: MSC / GCC differ in behaviour
Next Topic: RichPickToValue PROPOSAL
Goto Forum:
  


Current Time: Mon Aug 25 12:39:08 CEST 2025

Total time taken to generate the page: 0.05944 seconds