Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2004-08-06 02:57:56


Stefan Slapeta wrote:
> Daniel James wrote:
>
>> [many things]
>
>
> FYI, Thorsten checked in a test case (range/adl_conformance) to check
> ADL conformance on various compilers before he left for vacation.
>
> It's not that this testcase tells us much about the range library, but
> the results are nevertheless interesting and show that some compilers
> still have their difficulties! Among these are the (current) Microsoft
> compiler(s), but also Intel: once again the tests pass on Windows and
> fail on Linux (one should mean they have different front ends)!
>
> If there really is an intention to extend the use of ADL in the boost
> library, one perhaps should ask Microsoft to fix the issues in VC 8.

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

#include <iostream>

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 );
    }
}

namespace B
{
    class C {};

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

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

    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
The hacks that we write today become the bugs of tomorrow.

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