Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-08-13 13:10:43


Daniel Frey <daniel.frey_at_[hidden]> writes:

> Thorsten Ottosen wrote:
>> "Daniel Frey" <daniel.frey_at_[hidden]> wrote in message news:cfhteq$piv$1_at_sea.gmane.org...
>> |Hm, good point. The only "solution" I could come up with is shown
>> below,
>> |but I don't know how portable/robust it is.
>> |
>> | 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();
>> | }
>> why do you return an internal here? I mean, weed want to return
>> f(x).
>
> But we need to detect which f(x) is choosen in the sizeof. The ADL
> f(x) won't return internal, thus the operator, isn't applied, thus the
> sizeof( f(x),internal() ) is not sizeof( char ). How else could you
> detect which f(x) would be choosen? The above example also "wants" to
> return void, thus it should work. For non-void return types, the class
> internal' must be more complicated.
>
> But maybe someone else has a better (and robust enough) idea how to
> detect which f(x) would be called...

You can use something like what boost/detail/is_incrementable.hpp is
doing, but I think that's basically the same technique you're using.
And this seems to be exactly what I was talking about on the NG when I
suggested removing ambiguity by detecting whether there's a function
that could be found via ADL... or am I missing something?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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