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 » Developing U++ » U++ Developers corner » Core chat... (reference counted pointers etc.)
Re: Core chat... [message #12350 is a reply to message #12348] Thu, 25 October 2007 23:38 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14257
Registered: November 2005
Ultimate Member
mdelfede wrote on Thu, 25 October 2007 17:26

luzr wrote on Thu, 25 October 2007 21:33



You can try. However, long time ago, such class template was part of U++. But there was no use for it. "pick" is confusing at first, but quite powerful concept.




I do find "pick" quite clear. You get the top performance at at the expense of some loss of easy to use stuff.



Well, performance is nice, but really not that important.

What IS imporant is that there is only ONE PLACE where instance of (possibly) non-copyable object can exist.

Quote:


array<int> a, b;
a.At(1000) = 1;
b = a;      <== b and a share same memory area
a[10] = 2;  <== here an automatic deep copy, ok
b[10] = 2;  <== here no deep copy, just array access, ok




Note that above is impossible to implement reliably in C++ (as long as you want read operator[] access to perform no copy at all).

Quote:


array a gets 2 references to it for a while, just when MyFunc returns a value. Then, temporary from MyFunc get destroyed, leaving a with a single reference. Any subsequent access to a[] don't need a deep copy.



Sure. Anyway, the real point of pick is here:

Array<Ctrl> CreateWidgets()
{
    Array<Ctrl> x;
    ...
    return x;
}


Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ValueMap
Next Topic: Quick and dirty solution to .icpp problem...
Goto Forum:
  


Current Time: Sun May 11 22:45:57 CEST 2025

Total time taken to generate the page: 0.03755 seconds