implicit constructors

Timon Gehr timon.gehr at gmx.ch
Sat Nov 26 17:05:57 PST 2011


On 11/27/2011 01:56 AM, Timon Gehr wrote:
> On 11/27/2011 01:55 AM, Timon Gehr wrote:
>> On 11/27/2011 01:54 AM, Timon Gehr wrote:
>>> On 11/27/2011 12:14 AM, Trass3r wrote:
>>>> anyone?
>>>
>>> kk.
>>>
>>> struct A{
>>> struct S{A opAssign(int rhs){return *(cast(A*)&this)=A(rhs);}}
>>> union{
>>> struct{ // members
>>> int store;
>>> }
>>> S _x; // dummy struct
>>> }
>>> this(int a) {
>>> store = a << 16;
>>> //...
>>> }
>>> alias _x this;
>>> }
>>>
>>> void main(){
>>> A x;
>>> x = 2;
>>> assert(x.store == 2 << 16);
>>> }
>>
>> A a = 5;
>>
>> Does not work though.
>
> (Except in function scope, where it does.)

NVM, I misunderstood the issue (I thought there were never implicit 
constructors. If there were not, my program would implement them.)


More information about the Digitalmars-d mailing list