[Issue 4875] Allow struct initialization with constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 15 16:18:44 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4875



--- Comment #3 from bearophile_hugs at eml.cc 2010-09-15 16:18:13 PDT ---
Is this good enough?


struct HANDLE {
    size_t value = -1; // variables are lowercase in D

    this(void *ptrValue) {
        value = cast(size_t)ptrValue;
    }
    this(size_t intValue) {
        value = intValue;
    }

    void opAssign(void *ptrValue) {
        value = cast(size_t)ptrValue;
    }
    void opAssign(size_t intValue) {
        value = intValue;
    }
}

// alias size_t HANDLE;

class File {
    HANDLE handle;
    this() {
        handle = 5;
    }
}

void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list