Summary: inout parameter contravariant should be allowed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        Depends on: 7105

--- Comment #0 from Kenji Hara <> 2012-02-19 03:31:38 PST ---
After fixing issue 7105, we should allow inout parameter covariant.

Test cases:
void function(int* p) mfp;
void function(const(int)* p) cfp;
void function(immutable(int)* p) ifp;
void function(inout(int)* p) wfp;
wfp = mfp;
wfp = cfp;
wfp = ifp;
static assert(!__traits(compiles, wfp = function void(int**){}));
static assert(!__traits(compiles, wfp = function void(int[]){}));

void delegate(int* p) mdg;
void delegate(const(int)* p) cdg;
void delegate(immutable(int)* p) idg;
void delegate(inout(int)* p) wdg;
wdg = mdg;
wdg = cdg;
wdg = idg;
static assert(!__traits(compiles, wdg = delegate void(int**){}));
static assert(!__traits(compiles, wdg = delegate void(int[]){}));

void foo(T)(void delegate(inout(int)** p, inout(int)* v) dg)
    T* pm;
    T m;
    dg(&pm, &m);
    assert(pm == &m);
foo!(          int)((          int ** p,           int * v){ *p = v; });
foo!(    const int)((    const(int)** p,     const(int)* v){ *p = v; });
foo!(immutable int)((immutable(int)** p, immutable(int)* v){ *p = v; });

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to