Home » Community » Coffee corner » Basic questions about u++
Re: Basic questions about u++ [message #23301 is a reply to message #23298] |
Wed, 07 October 2009 19:14 |
|
mirek
Messages: 13980 Registered: November 2005
|
Ultimate Member |
|
|
irtech wrote on Wed, 07 October 2009 12:47 |
mrjt wrote on Wed, 07 October 2009 18:14 |
By wrapping the new/delete calls in an object (one that has already been thoughly tested) you are able to utilise C++ inbuilt destruction mechanics and avoid the error-prone call to delete. There isn't any 'magic' going on outside of using templates in a clever way
As far as I'm concerned the Upp memory management philosophy is to never use new/delete. There is almost always a better way .
|
Ok thanks with your explanation and what I've read in overview now I understood the resource management philosophy of U++!
except one thing !
Ok your example is about a simple int but hw about a big object like a class? Then you certainly need copy constructor which seems to be the motive not to use stdlib.
|
Actually, in most cases, you do NOT need copy constructor.
Quote: |
I mean for example I want to specifically copy value of a sibling object when copy constructor is called or I want to increment a variable inside a class inside copy constructor so I know how many times it has been copied.
|
Well, you have 3 kinds of entities:
- "object" (I lack better word) classes like File, Window etc... These usually do not have copy.
- "value" types like int, String, Color etc... These usually have full deep copy semantics
- and, U++ specific "containers". These act as sort of structural glue binding everything together.
And these containers, to workaround possibly missing copy contructors in cointained objects, have so called "pick transfer semantics":
http://www.ultimatepp.org/srcdoc$Core$pick_$en-us.html
which is the most "alien" thing in U++.
In reality, we could probably even live without pick, it is sort of similar in importance to "break" statement in C(++/#)/Java. But it makes live easier.
Mirek
[Updated on: Wed, 07 October 2009 19:14] Report message to a moderator
|
|
|
|
|
Basic questions about u++
By: irtech on Tue, 06 October 2009 14:14
|
|
|
Re: Basic questions about u++
By: mr_ped on Tue, 06 October 2009 14:41
|
|
|
Re: Basic questions about u++
By: mr_ped on Tue, 06 October 2009 15:03
|
|
|
Re: Basic questions about u++
By: irtech on Tue, 06 October 2009 15:30
|
|
|
Re: Basic questions about u++
By: zsolt on Tue, 06 October 2009 15:51
|
|
|
Re: Basic questions about u++
By: irtech on Wed, 07 October 2009 06:19
|
|
|
Re: Basic questions about u++
|
|
|
Re: Basic questions about u++
By: mirek on Wed, 07 October 2009 08:29
|
|
|
Re: Basic questions about u++
By: mirek on Wed, 07 October 2009 08:46
|
|
|
Re: Basic questions about u++
By: mr_ped on Wed, 07 October 2009 09:04
|
|
|
Re: Basic questions about u++
By: mirek on Wed, 07 October 2009 09:46
|
|
|
Re: Basic questions about u++
By: irtech on Wed, 07 October 2009 10:04
|
|
|
Re: Basic questions about u++
|
|
|
Re: Basic questions about u++
By: mr_ped on Wed, 07 October 2009 10:45
|
|
|
Re: Basic questions about u++
By: unodgs on Wed, 07 October 2009 11:54
|
|
|
Re: Basic questions about u++
By: irtech on Wed, 07 October 2009 12:11
|
|
|
Re: Basic questions about u++
By: mirek on Wed, 07 October 2009 12:23
|
|
|
Re: Basic questions about u++
By: mr_ped on Wed, 07 October 2009 13:33
|
|
|
Re: Basic questions about u++
By: irtech on Wed, 07 October 2009 16:18
|
|
|
Re: Basic questions about u++
By: chickenk on Wed, 07 October 2009 17:46
|
|
|
Re: Basic questions about u++
By: mrjt on Wed, 07 October 2009 18:14
|
|
|
Re: Basic questions about u++
By: irtech on Wed, 07 October 2009 18:47
|
|
|
Re: Basic questions about u++
By: mrjt on Wed, 07 October 2009 19:07
|
|
|
Re: Basic questions about u++
By: mirek on Wed, 07 October 2009 19:14
|
|
|
Re: Basic questions about u++
By: mr_ped on Wed, 07 October 2009 21:28
|
Goto Forum:
Current Time: Mon May 13 19:47:16 CEST 2024
Total time taken to generate the page: 0.02787 seconds
|