16-07-2008, 03:44 PM
Firstly, the example is incorrect. Thank you for highlighting this.
The key motivation for this rule comes from a proposal to C++ 0X to "Fix ADL". (http://www.open-std.org/jtc1/sc22/wg21/d.../n1893.pdf)
Unfortunately C++ today does not have the recommended restrictions to ADL, and so the only way to ensure that none of the problems outlined here can occur is by disabling it completely.
One of the more interesting examples is the following:
// Example 2.3
//
#include
namespace N {
struct X { };
template
int* operator+( T , unsigned )
{ static int i ; return &i ; /* just to stub in the function body */ }
}
However, please read the complete paper for a description on why ADL in its current form is of concern.
Regards,
Richard
The key motivation for this rule comes from a proposal to C++ 0X to "Fix ADL". (http://www.open-std.org/jtc1/sc22/wg21/d.../n1893.pdf)
Unfortunately C++ today does not have the recommended restrictions to ADL, and so the only way to ensure that none of the problems outlined here can occur is by disabling it completely.
One of the more interesting examples is the following:
// Example 2.3
//
#include
namespace N {
struct X { };
template
int* operator+( T , unsigned )
{ static int i ; return &i ; /* just to stub in the function body */ }
}
However, please read the complete paper for a description on why ADL in its current form is of concern.
Regards,
Richard
<r>-- <br/>
Richard Corden<br/>
Programming Research Ltd.<br/>
<EMAIL email="[email protected]">[email protected]</EMAIL><br/>
+ 44 845 0048478</r>
Richard Corden<br/>
Programming Research Ltd.<br/>
<EMAIL email="[email protected]">[email protected]</EMAIL><br/>
+ 44 845 0048478</r>