[Issue 5234] New: [qtd] AA element assignment should use copy-constructor to initialize new elements

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 18 08:24:16 PST 2010


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

           Summary: [qtd] AA element assignment should use
                    copy-constructor to initialize new elements
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: samukha at voliacable.com


--- Comment #0 from Max Samukha <samukha at voliacable.com> 2010-11-18 08:23:00 PST ---
Currently opAssign is called on newly created AA elements of struct types. This
leaves us absolutely no possibility to properly initialize AA elements without
introducing costly and unreliable checks in opAssign:

struct QString
{
    ref QString opAssign(ref QString other)
    {
        if (memcmp(cast(void*)&this, cast(void*)&T.init, sizeof(this)) == 0)
        {
            // construct copy
        }
        else
        {
            // assign
        }
    }
}

QString[int] ss;
QString s = qs("some string");
ss[0] = s;

Can AA be modified so that new elements are initialized with the
copy-constructor (as they should be) and not opAssign?

-- 
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