"Peter Dimov" wrote in message
news:001a01c520c7$6b03f790$6501a8c0@pdimov2...
| David Abrahams wrote:
| > I guess I haven't seen enough be definitively convinced one way or the
| > other. I have heard stories from people who switch to dispatching via
| That's the thing. It doesn't actually buy us anything. It only claims to
| avoid potential problems.
| * Does not allow a base-specific version to be picked up automatically for
| derived classes.
This seems only to be possible with ADL if there is no primary template;
otherwise the
primary template will often be a better match than the derived type, eg.
#include <iostream>
namespace Foo
{
template< class T >
void foo( const T& r )
{
std::cout << "foo";
}
}
namespace Boo
{
//template< class T >
struct X
{
};
//template< class T >
struct Y : public X//<T>
{
};
// template< class T >
void foo( const X& r )
{
std::cout << "boo";
}
}
int main()
{
//
// This statement will alter the behavior!
// Therefore, all classes that overload
// foo, must specialize foo if they are templates
//
using namespace Foo;
Boo::X x;
Boo::Y y;
foo( x );
foo( y );
}
will print "boofoo".
-Thorsten