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 » Vcont.h and Vcont.hpp Change required
Vcont.h and Vcont.hpp Change required [message #56760] Mon, 12 April 2021 06:41 Go to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

Small change required in Vcont.h @Line 195

Original
T&       Add(const T& x)                 { return items < alloc ? *(new(Rdd()) T(x)) : GrowAdd(x); }


Changed
T&       Add(const T& x)                 { return items < alloc ? *(new(Rdd()) T(clone(x))) : GrowAdd(clone(x)); }



Also Change in Vcont.hpp file @line 140

Original
T *q = new(Rdd()) T(x);


Changed
T *q = new(Rdd()) T(clone(x));



Warm Regards

Deepak

[Updated on: Mon, 12 April 2021 06:43]

Report message to a moderator

Re: Vcont.h and Vcont.hpp Change required [message #56801 is a reply to message #56760] Sat, 17 April 2021 06:13 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I believe this would allow

Vector<Vector<int>> vv;
Vector<int> v;
....
vv.Add(v);


with silent deep copy performed. This is something we want to avoid. We want you to be explicit and either use

vv.Add(pick(v));


or

vv.Add(clone(v));



Add(const T&) variant is reserved for types with full copy semantics (e.g. int or String).

Mirek
Previous Topic: build with clang-mingw on Linux is broken
Next Topic: Any Example of Inverse a Matrix in U++?
Goto Forum:
  


Current Time: Thu Mar 28 16:18:23 CET 2024

Total time taken to generate the page: 0.01070 seconds