Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2008-08-05 11:26:55


Folks I have a large amount of code that generates warnings of the kind:

   t.cpp:6: warning: shadowing built-in function `double std::acos(double)'

Actually many thousands of these warnings when building with g++ -Wshadow
:-(

Normally I would just fix the code, but in this case I don't see how, I have
code that looks like:

#include <cmath>

template <class T>
T f(T v)
{
   // We want acos found via ADL in case T is a class type:
   using std::acos;
   return acos(v);
}

int main()
{
   f(2.0);
   return 0;
}

Which just on it's own produces:

$ g++ -I. -Wall -Wshadow -c t.cpp 2>&1 | less

t.cpp: In function `void f(T)':
t.cpp:6: warning: shadowing built-in function `double std::acos(double)'
t.cpp: In function `void f(T) [with T = double]':
t.cpp:12: instantiated from here
t.cpp:6: warning: shadowing built-in function `double std::acos(double)'
t.cpp:12: instantiated from here

But I can't see any other way to code this... certainly using a "using
namespace std;" in place of the "using std::functionname;" is *not* a valid
fix (it can lead to lookup ambiguities).

Any ideas folks?

Thanks, John.


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