
Boost : 
From: Daniel Spangenberg (dsp_at_[hidden])
Date: 20030722 08:31:23
Daniel Frey schrieb:
> I guess you missed the fact that X<T> in the operators library defines
> operators which take T as an argument, not X<T>. Whether X<T> is
> associated with T is therefore not important here, ADL matches the
> operator arguments, not the class which declared the operator.
>
> Regards, Daniel
No, I absolutely do understand, that X<T> in the operators library defines
operators which take T as an argument. I hope, that my explanation meant that
(my english is bad, I know). But I think, that the standard does forbid the
visibiliy
of the operators injected by less_than_comparable<myclass> for myclass
because myclass is not the associated with less_than_comparable<**>. Now the
operators injected by less_than_comparable<myclass> take myclass as
arguments (those with arguments, I mean) and should noot be visible for
myclass.
Let's look at the example of the standard (which is not binding, of course),
template<typename T> class number {
number(int);
//...
friend number gcd(number& x, number& y) { /* ... */ }
//...
};
void g()
{
number<double> a(3), b(4);
//...
a = gcd(a,b); // finds gcd because number<double> is an
// associated class, making gcd visible
// in its namespace (global scope)
b = gcd(3,4); // illformed; gcd is not visible
}
I am aware, that this example does not hit the exact problem, but it
is quite near (There is also seems to be a bug in this example, as explained in
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#387, but that
does not matter here, because it essence is not affected).
I think, you can transform this example to the following
template<typename T> class number {
public: // Changed according to 387
template <typename U> // ** Changed here
number(U); // ** Changed here
//...
friend number gcd(number& x, number& y) { /* ... */ }
//...
};
void g()
{
myclass three, four; // ***Added this here
number<myclass> a(three), b(four); // ***Changed here
//...
a = gcd(a,b); // finds gcd because number<double> is an
// associated class, making gcd visible
// in its namespace (global scope)
b = gcd(three,four); // illformed; gcd is not visible // **Changed here
}
Or am I missing something??
Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk