RE: [sv-bc] RE: [sv-ec] overloading an assignment operator

From: Subhamoy Pal <spal_at_.....>
Date: Thu Apr 12 2007 - 23:20:35 PDT
Hi Steven,

What you are saying is just one possibility right? You want += to be
composed by independent overloading + and =.

But if you check the list of operators can be overloaded, you will see
+= itself is a valid operator for overloading. So, we can do 

 

typedef struct {

    int Real;

    int Imaginary

} complex;

 

function complex add_assign(complex in1, int in2)

{

    in1.Real = in1.Real + in2;

    add_assign.Real = in1.Real;

    add_assign.Imaginary = in1.Imaginary;

}

 

bind += function complex add_assign(complex in1, int in2);

 

And in this case, += (just an assignment operator) becomes binary?

 

Thanks,

Subhamoy

 

-----Original Message-----
From: Steven Sharp [mailto:sharp@cadence.com] 
Sent: Friday, April 13, 2007 12:45 AM
To: Dave_Rich@mentor.com; sharp@cadence.com; sv-ec@eda-stds.org;
sv-bc@eda-stds.org; Subhamoy Pal
Subject: RE: [sv-bc] RE: [sv-ec] overloading an assignment operator

 

I believe that "LHS += RHS" is treated as if it were decomposed into

"LHS = LHS + RHS", except that LHS is evaluated only once.  So the

addition and assignment operators would be overloaded independently,

and the += operator would be composed from them.

 

Steven Sharp

sharp@cadence.com

 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Apr 12 23:20:19 2007

This archive was generated by hypermail 2.1.8 : Thu Apr 12 2007 - 23:20:30 PDT