$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2004-08-13 03:17:30
Thorsten Ottosen wrote:
> 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.
Hm, good point. The only "solution" I could come up with is shown below, 
but I don't know how portable/robust it is.
#include <iostream>
namespace A
{
    // For this test, we assume sizeof(char) < sizeof(double)
    class internal { double dummy; };
    char operator,( const internal&, const internal& );
    template< typename T >
    internal f( const T& x )
    {
       if( sizeof( f(x),internal() ) == sizeof( char ) ) {
          // Non-ADL-implementation
          std::cout << 1 << std::endl;
       }
       else {
          // ADL-forwarder
          f( x );
       }
       return internal();
    }
    class 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 );
    B::C c;
    A::f( c );
}
Regards, Daniel
-- Daniel Frey aixigo AG - financial solutions & technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de