Boost logo

Boost Users :

Subject: Re: [Boost-users] A question on overloaded function? Can anyone with kindness help me?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-30 16:36:06


AMDG

fmingu wrote:
> I use Dev-C++,and the snipet of the program is:
> #pragma hdrstop
> # include <iostream>
> # include <vector>
> # include <iterator>
> # include "boost/math/common_factor.hpp"
> # include "boost/lambda/lambda.hpp"
> # include "boost/lambda/bind.hpp"
> # include "boost/lambda/if.hpp"
> # include "boost/lambda/casts.hpp"
> # include "boost/lambda/construct.hpp"
> # include "boost/lambda/loops.hpp"
> # include "boost/lambda/switch.hpp"
> # include "boost/tuple/tuple.hpp"
> # include "boost/tuple/tuple_comparison.hpp"
> # include <string>
> # include <map>
>
> using namespace std;
> using namespace boost::lambda;
> using namespace boost;
>
> void a(){
> std::cout<<std::pow(4,3);
> return;
> }
> ...............
> but the complier told me that:
>
> main2test.cpp: In function `void a()':
> main2test.cpp:69: call of overloaded `pow(int, int)' is ambiguous
> F:/CB2009/Dev-Cpp/include/math.h:162: candidates are: double pow(double, double)
> F:/CB2009/Dev-Cpp/include/c++/cmath:401: float std::pow(float, float)
> F:/CB2009/Dev-Cpp/include/c++/cmath:410: long double
> std::pow(long double, long double)
> F:/CB2009/Dev-Cpp/include/c++/cmath:419: double
> std::pow(double, int)
> F:/CB2009/Dev-Cpp/include/c++/cmath:423: float std::pow(float,
> int)
> F:/CB2009/Dev-Cpp/include/c++/cmath:427: long double
> std::pow(long double, int)
>
> And in my computer, the C++ libraries includes are
> F:\CB2009\Dev-Cpp\include\c++
> F:\CB2009\Dev-Cpp\include\c++\mingw32
> F:\CB2009\Dev-Cpp\include\c++\backward
> F:\CB2009\Dev-Cpp\include
> F:\CB2009\boost_1_34_1\boost_1_34_1
> I do not know how to solve it.

There is no overload of std::pow that takes two ints.
You need to match one of the possible signatures exactly.

> I do not use <math> or <cmath> yet.
> Why the complier told me such files? And whether the two files are included in other files or not?
>

Apparently cmath is included indirectly by some other header file.
This is hardly an unusual occurrence in C++...

> And can I use:
> bind(&std::pow,constant(-1),bind(&IIPrimemap::size,var(primemapvec)));
>

You can't pass the address of an overloaded function to
a function template like bind without casting it to the
correct function pointer type.

> in the program? where :
> typedef std::pair<int, int> IIPrimepair;
> std::vector<IIPrimepair> primepairvec;
>
> Can anyone with kindness help me?

In Christ,
Steven Watanabe


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