Boost logo

Boost Users :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-04 12:19:08


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:001a01c520c7$6b03f790$6501a8c0_at_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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net