Topic: Help...changes that broke my code...


Author: abed@ritz.cec.wustl.edu (Abed Hammond)
Date: 1995/06/30
Raw View
Hello,

I had written a set of classes vectors/matrices/etc...that I have
been using for years and they are doing the job great...

In these classes I overload the relational operators
!= == <= > ..etc so the for example if I have the
following two 1D arrays:

v1 = [1 2 3 4] and v2 = [2 2 0 4]

The resluts of the call: v1 == v2 is [0 1 0 1], i.e. I do the check in
an element by elment fashion. This is something similar to the way
matlab does it.

The above enables me from writting code like

if (any(v < 0))
   // Some elements of v are negative

if (all(v > ))
   // All elements of v are positive.

v(where(v > 2)) = 5;  // Set all elements of v > 2 to 5.

The above is really neat and save me a lot of typing and is very readable.


The problem now is that I just installed the new version of my comipler
which supposedly confirms (more or less) to the standard. The
compiler defines global operators !=, >, <=, >= interms of
other relational operators along the line of what is discussed
in section 20.2.1 (operators) sections of the standard document.

These operators return the type bool, white the member operators
that I have defined return vectors/matrices of bool.

So the moral of the story is I am getting a lot of errors saying
that my calls to operators != == etc is ambigus.

Please let me know what you think. Should I be able to overcome
this problem.

If not then could some one please tell me why do we need to define
these global functions. How about trusting the user to do the
right thing.

Please help,
Thanks,

============================================================================
Abed M. Hammoud, D.Sc.                          a.hammoud@ieee.org

Surgical Navigation Technologies       -Voice: (314) 863-0817
Colorado, USA          -Fax:   (314) 935-4842
============================================================================