Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-23 14:59:51

Andy Little wrote:
> "Tobias Schwinger" wrote
> Andy Little wrote
>>>I have just been reading n1792 "A modest proposal fixing ADL". In it Herb
>>>Sutter states that only two compilers of those tried VC8 and Com4.3.3 do ADL
>>>correctly, so maybe this is behind your problems.
>>It definitely isn't - the case cited is much clearer than the one in the article.
>>Further, ADL *is* working correctly on the same operator and the same types in
>>a different context.
> Sorry about that. I've been going round and round trying to find out what I did
> wrong, but this time it does seem that I am right that the compiler is wrong
> ... so to speak. If so its very disappointing. I had been looking forward to
> using VC8

I'm sure it can be worked around (the one way or the other).

> I tried out the example. VC8 doesnt seem to like operator + much does it? or - /
> * for that matter.

Well, we're talking about two (probably closely related) bugs here:

1) The deduction in boost::spirit::operator+ fails (which can -for some odd
reason- be worked around by overloading the operator).

2) ADL doesn't work. When using the commented line (instead of "using
namespace...") in this part

    // using boost::spirit::anychar_p;
    using namespace boost::spirit;
    // ADL doesn't seem to work, either but I could live with this problem ;-)

of the code, the operator isn't found at all. The commented line is perfectly
enough in the non-templated case, though (the case you get if MAKE_THINGS_FAIL is
not defined).

Also note that these problems are not limited to operators -- they applly to
functions in general.

> What should be done about it. Should someone start reporting this to the folks
> at Microsoft or what?

Definitely. But we should first minimize the case and try to find out what exactly
causes VC8 to turn off ADL (the same situation probably also activates bug1, above).

How does the declaration of your operator- look like?

Does it instantiate templates that use sizeof- or conditional tricks (as

There must be /something/ going on, because for "pure expression templates" (e.g.
Spirit without Typeof) ADL works fine. There would be problems with other Boost
libraries as well, I figure.

Here's a suggestion for a rather pragmatic solution:

    // at root namespace
    using [...] operator [...];
    using [...] operator [...];

if that won't help, define the operators at root namespace for that compiler.
Of course you should use restricted parameters rather than fully general templates
that match everything:

    // This one means trouble when injected into the root namespace
    template<typename T0,typename T1>
    typename result<T0,T1>::type operator-(T0 const &, T1 const &);

    // This one should be mostly (because implicit conversion ctors in
    // boost::pqs::some_template could still cause trouble) harmless.
    template<typename T0,typename T1>
    typename result<T0,T1>::type operator-(boost::pqs::some_template<T0> const &,
                                           T1 const &);



Boost list run by bdawes at, gregod at, cpdaniel at, john at