Topic: Proposal: Namespace qualifying overloaded operators


Author: erik.westlin@abc.se ("Erik Westlin")
Date: Tue, 15 Nov 2005 17:16:04 GMT
Raw View
Consider:

class Foo
{
};

namespace ns
{
     Foo operator*(Foo,Foo);
     Foo mul(Foo,Foo);
}

void func()
{
     Foo a,b;

     // this works
     using namespace ns;
     a * b;

    // or
    ns::operator* (a, b);


     // but
     a ns::* b
     // doesn't work at all.

     However i think it would be useful
     Think about matrix algebra with several different multiplication
operators
     It would make it possible to write expressions like

     a inner::* b outer::* c

     Maybe that would be even better than the algebraic typo where a lot of
new
     characters are invented.

     well it might be too hard for the compiler to implement.
     or there are some other objection?
     or this may already have been done in some compiler?

     I know it's just syntactic sugar but why shouldn't you be able
     to namespace qualify operators when you can with everything else.

}

Cheers

Erik Westlin




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