Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-08-12 12:58:16


Maybe the following helps to create a more robust version of the idiom,
as it doesn't need 'using' at all:

[snip]

I think this won't work afterall.

If I put a class into namespace A, I will get ambiguity.

namespace A
{
    namespace detail
    {
       template< typename T >
       void f( const T& )
       {
          std::cout << 1 << std::endl;
       }

       template< typename T >
       void adl_f( const T& x )
       {
          f( x );
       }
    }

    template< typename T >
    void f( const T& x )
    {
       detail::adl_f( x );
    }

// this is bad!!
    struct C {};
}

namespace B
{
    class C {};

    void f( const C& )
    {
       std::cout << 2 << std::endl;
    }
}

int main()
{
    A::f( 42 );

    A::C c0;
    A::f( c0 ); // error!

    B::C c;
    A::f( c );
}

br

Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk