Timeline for Template vector class
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 13, 2013 at 20:35 | comment | added | Loki Astari | @bamboon: You are correct on both points. I have fixed the easy one. Calling the destructor I have not done here because that is a lot of work (you can't just do the obvious because pointers and fundamental types don't have destructors). | |
Nov 13, 2013 at 20:29 | history | edited | Loki Astari | CC BY-SA 3.0 |
edited body
|
Nov 13, 2013 at 19:24 | comment | added | inf |
Hi Loki, I was just wondering two things and I am interested in what you think about them. First, shouldn't the unique_ptr<char be a unique_ptr<char[]> so that the correct version of delete is called? Second, don't you have to destroy all already constructed elements in the constructors when a T constructor would throw an exception.
|
|
Aug 3, 2013 at 18:40 | history | edited | Loki Astari | CC BY-SA 3.0 |
added 4337 characters in body
|
Aug 3, 2013 at 18:36 | comment | added | Loki Astari | Updated with an example of how I might do it. Needs some cleanup but it should work. | |
Aug 3, 2013 at 18:34 | history | edited | Loki Astari | CC BY-SA 3.0 |
added 4337 characters in body
|
Aug 3, 2013 at 17:26 | vote | accept | Anmol Singh Jaggi | ||
Aug 3, 2013 at 11:38 | comment | added | Lstor |
The "similar question" is about delete , which frees memory. @LokiAstari is talking about calling the destructor, which causes the object in question to clean up the resources it owns: elem->~T();
|
|
Aug 3, 2013 at 10:41 | comment | added | Anmol Singh Jaggi |
Making the size smaller is easier....manually call the destructor on all the objects that don't exist anymore. How can we do it??! I asked a similar question some time back. Similarly, in erase() , how to destruct a single element? ( except for the usual way of reallocating ) . In, reserve() , // The trouble with use T as the ....constructor on values upto newcapacity .. I don't get it..Is there any other way too?
|
|
Aug 3, 2013 at 7:48 | history | answered | Loki Astari | CC BY-SA 3.0 |