Destructors, const structs, and opEquals

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Dec 21 10:58:57 PST 2010


On 10/12/2010 21:17, Andrei Alexandrescu wrote:
> We all need to think about this a bit more because it's related to
> another issue that I'm still losing sleep over: should we promote cheap
> copy construction throughout D or not?

I was reminded of another comment that could be said in favor of that: 
If you look back at your own article and thoughts about ranges and 
iteration, you made the case for the benefits of the iteration 
primitives having complexity guarantees (just as is the case with STL). 
It seems to me that the very same reasoning could be applied to these 
fundamental type primitives, like the copy constructor at least. If the 
copy constructor guarantees constant complexity, then other algorithms 
and operations can be built on top of that, and also provide useful 
complexity guarantees. Like the sort example you mentioned.

(Hum, and if we go this way, it will probably be best not to call it 
"copy constructor" then)

-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list