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 » Unsafe Deep Copy
Unsafe Deep Copy [message #8787] Sat, 31 March 2007 12:11 Go to next message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
I think there might be an issue with the following code

template <class T, class B = EmptyClass>
class DeepCopyOption : public B {
public:
	friend T& operator<<=(T& dest, const T& src)
	{ (&dest)->T::~T(); ::new(&dest) T(src, 1); return dest; }
        ...
};


The issue occurs when you are self deep copying :
a <<= a;

One solution is
	friend T& operator<<=(T& dest, const T& src)
	{ if (&src != &dest) {(&dest)->T::~T(); ::new(&dest) T(src, 1);} return dest; }
Re: Unsafe Deep Copy [message #8790 is a reply to message #8787] Sat, 31 March 2007 17:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks.

Mirek
Re: Unsafe Deep Copy [message #8791 is a reply to message #8790] Sat, 31 March 2007 18:00 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
PS.: As this is not too serious flaw, I have fixed it in newcore only...

Mirek
Previous Topic: XmlIO - New function proposal
Next Topic: StrDbl and decimal separator
Goto Forum:
  


Current Time: Thu Apr 18 08:29:11 CEST 2024

Total time taken to generate the page: 0.02158 seconds