opAssign and template class
Ali Çehreli
acehreli at yahoo.com
Wed Feb 5 09:56:00 PST 2014
On 02/05/2014 09:37 AM, dbjdbj wrote:>
> Impressive but please next time please use: http://dpaste.dzfl.pl/ ...
I disagree. dpaste has no association with this newsgroup and can
disappear at any time in the future.
>
> Depressive is this issue (and some more) since I was sincerely hoping I
> could live C++ "behind" ...
>
> Eh ...
There is a significant difference between D and C++. In D, classes are
reference types (not value types).
The equivalent in C++ of what you are trying to do would be overriding
the assignment operator for class pointers, which is not possible in C++:
// C++ code:
X * x_ = new X() , // created:1 , alive: 1
* x2 = x_ ; // created:1 , alive: 2 (not possible!)
Same limitation in D...
Ali
More information about the Digitalmars-d
mailing list