#include
<iostream>
using std::cout;
using std::endl;
namespace MySpace {
template <class
T>
class A
{
public:
A(const T &t) : t_m(t) { }
T t_m;
};
template <class
T>
T sum(const T &t1, const T &t2)
{
return T(t1.t_m + t2.t_m);
}
int sumInt(int t1, int
t2)
{
return t1 + t2;
}
}
int main()
{
MySpace::A<int> a(1);
MySpace::A<int> b(2);
MySpace::A<int> c =
sum(a,b);
cout << "A(1) + A(2) =
" << c.t_m << endl;
cout << "1 +
2 = " << MySpace::sumInt(1,2) <<
endl;
return
0;
}
The
line of note is "c = sum(a,b)". If Koenig lookup is implemented, the function
"sum" does not need to be qualified with MySpace::, unlike the call to sumInt,
which does need to be qualified.
This
appears to work with GCC 2.95, but I seem to recall that there are problems with
its implementation. Marks says 3.00 works. It does not work with VC++6.0 or,
surprisingly, with Intel VTune 5.0. The latter, along with SGI's CC, may be the
main showstoppers.
Jim
-----Original Message-----
From:
Julian C. Cummings [mailto:address@hidden
Sent: Monday, July
09, 2001 5:17 PM
To: James Crotinger
Subject: RE:
[pooma-dev] std:: Policy for PoomaOps.in?
Jim,
Do
you have any little example codes that test the
Koenig lookup functionality? I'd be happy to run
them
through Intel VTune and see what happens.
I
should look at what Blitz does regarding this issue.
I
know that Blitz Arrays and other objects are in a
blitz namespace, but of course _expression_ templates
are
handled differently than in Pooma.
Julian C.
> -----Original Message-----
>
> Hi Mark,
>
> I guess you meant GCC-3.0.
>
> I don't know which compilers are
used for POOMA but I used to have
> reports that
VC++-6.0 has serious problems with Koenig lookup. I
> don't know the case for other compilers.
VC++6.0 isn't a target platform - it doesn't even support
partial specialization. I'm not sure what the situation is with the Intel
VTune compiler, though (wrt Koenig lookup).
Jim