Home » U++ Library support » U++ Core » Unsafe Deep Copy
Unsafe Deep Copy [message #8787] |
Sat, 31 March 2007 12:11 |
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; }
|
|
|
|
|
Goto Forum:
Current Time: Thu Apr 18 08:29:11 CEST 2024
Total time taken to generate the page: 0.02158 seconds
|