www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2444] New: structs should allow calling the normal blitting function when overriding opAssign

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2444

           Summary: structs should allow calling the normal blitting
                    function when overriding opAssign
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: schveiguy yahoo.com


In D1, if I overload opAssign in a struct, I cannot create an overload that
takes the struct as an argument.  This is marked as illegal.

However, in a recent version of D2 (not sure which one), this became legal. 
However it has a bad side effect.  If I want to overload opAssign for an
argument other than the struct, for example an int, then it masks the overload
that just does the blitting.  I have to re-implement the blitting version.

I understand that an author may want to control opAssign to the point of
disallowing simple blitting copy.  But if desired, it is a PITA to do the
blitting manually.  It would be nice to be able to alias the original function,
or flag the struct somehow so that the compiler will use the blitting function
when assigning one struct to another.


-- 
Nov 06 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2444


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Severity|normal                      |enhancement




-- 
Jan 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2444


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



16:21:12 PST ---
I think you can implement this now as:

struct Foo
{
    void opAssign(const Foo rhs)
    {
        this.tupleof = rhs.tupleof;
    }
}

Maybe it should be added to the docs.

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