Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-11-16 05:13:57

Joaquín Mª López Muñoz wrote:
>>> 2. If the latter passes, try the attached test fsudba.cpp,
>>> which exercises an alternative way in which using declarations
>>> at function scope can break ADL.
>> Here's the output of :
>> > xlC fsudba.cpp
>> "fsudba.cpp", line 11.28: 1540-0256 (S) A parameter of type "foo<int>
>> &" cannot be initialized with an expression of type "int".
>> "fsudba.cpp", line 11.28: 1540-1205 (I) The error occurred while
>> converting to parameter 1 of "foo<int>::swap(foo<int> &)".
>> "fsudba.cpp", line 8.14: 1540-0700 (I) The previous message was
>> produced while processing "foo<int>::swap(foo<int> &)".
>> "fsudba.cpp", line 24.8: 1540-0700 (I) The previous message was
>> produced while processing "main()".
> Bingo :)
> John, do you think then that
> should be defined for __IBMCPP__<=800? Also, if you think it's
> appropriate
> I can add the test above to
> libs/config/test/boost_no_using_breaks_adl.ipp.

Hmmm, the interesting thing is, I'm having a hard time convincing myself
that this code is legal, I'm cc'ing our friendly IBM compiler expert in case
he can shed light on this.

Consider the code again:

#include <algorithm>

template<typename T>
struct foo
 T t;
 void swap(foo& x)
   using std::swap;

template<typename T>
void swap(foo<T>& x,foo<T>& y)

int main()
  foo<int> x,y;

In foo::swap the local declaration of the member function "swap" hides any
occurances of swap in the outer scope, and the using declaration behaves "as
if" std::swap were imported into the *enclosing namespace*, which would
still be hidden... and yet I can't believe that this simple idiom isn't
actually legal ! :-) And indeed all the other compilers I tested do compile
this OK.

Whatever the issue is, it's not really the same as
is the same as yet :-(

On the other hand extending the scope of

At present, confused yours, John.

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