D - more or less power than C++?

Oskar Linde olREM at OVEnada.kth.se
Sat Mar 4 05:56:30 PST 2006


Ben Phillips wrote:

> In article <dubfs7$95p$1 at digitaldaemon.com>, Andrew Fedoniouk says...
>>
>>I am not exactly sure what this means: assign-at-compile-time,
>>assign-once. Could you provide some examples?
>>
>>I mean something like
>>
>>struct cow_string {
>>   ref_counted_buffer data;
>>   void opAssign(cow_string s)
>>   {
>>       release(data);
>>       data = s.data;
>>       addref(data);
>>   }
>>}
>>
> 
> Since D uses references for all classes, providing opAssign is just way to
> dangerous to be worth the effort.

My suggestion is not to provide opAssign for classes. It is providing
opAssign for structs.

/Oskar



More information about the Digitalmars-d mailing list