Boost logo

Boost Users :

Subject: Re: [Boost-users] A question on overloaded function? Can anyone with kindness help me?
From: Asif Lodhi (asif.lodhi_at_[hidden])
Date: 2009-07-05 16:18:47


Hi,

On 6/30/09, fmingu <fmingu_at_[hidden]> wrote:
> I use Dev-C++,and the snipet of the program is:
> ............
> using namespace std;
> using namespace boost::lambda;
> using namespace boost;
>
> void a(){
> std::cout<<std::pow(4,3);
> return;
> }

I am not an expert but always try to use the using directives "using
namespace xxx" as locally as possible. You could have used the using
directives inside the function a() inside of dumping all of the
namespaces globally.

Moreover, may be you can do with std::pow ( 4.0, 3.0 ) to let the
compiler see clearly that you are interested in the "double, double"
version of pow() instead of the one based on integer arguments.

In addition, may be you can enclose your relevant code inside your own
namespace then you can typedef the specific overloaded version of the
std::pow() function in your namespace to let the compiler resolve
pow() call in your favor - to the locally declared pow() in your
namespace instead of the other ones in std namespace.

Alternatively, you declare and typedef a local pointer to the specific
std::pow function in your code and then pass that pointer instead to
the function you are interested in calling.

-Asif


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net