Topic: Overloading composite operators?


Author: hyrosen@mail.com (Hyman Rosen)
Date: Fri, 13 Aug 2004 21:05:00 GMT
Raw View
bq wrote:
> What is the current status on a revision of ISO C++, specifically
> regarding plans for overloading composite operators?

Not to do it.

> By "overloading composite operators" I mean conversion of an expression
 > like A = B * C; into a single function call

You can do this now using expression templates.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: fouad_qaqish@yahoo.com (bq)
Date: Fri, 13 Aug 2004 19:10:21 GMT
Raw View
Hello,
  This post is really two questions.
Question 1:
What is the current status on a revision of ISO C++, specifically
regarding plans for overloading composite operators? Some people in
this group would know. By "overloading composite operators" I
mean conversion of an expression like
    A = B * C;
into a single function call (instead of three calls; one to "*",
another to copy and another to "="). Here A, B and C are of a
user-defined class type, say a type that represents matrices.

Question 2:
I've read quite a bit about using "lazy evaluation" to avoid
unnecessary copying. Lazy evaluation seems fairly complex and runs
into problems when an object appears more than once in an expression
e.g. matrix multiplication of the form
   A = A * A;
or
   A = B + C * A;
The advantage of overlaoding the composites "= *", "= +", etc, is that
the function that gets to do the work will have access to A, B and C,
so it can detect any aliasing and then behave accordingly. I am new to
C++ (only read Koenig & Moo, currently reading Josuttis' STL book), so
I'd like to know what the experts think of this issue. Does
overloading composite operators obviate the need for lazy evaluation?

Thanks.
bq

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]