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-07-02 00:50:26


AMDG

fmingu wrote:
> Sorry for my unclearness. But how can I write the line:
> bind(&std::pow,constant(-1.0),bind(&IIPrimemap::size,var(primemapvec)));
> correctly and thus the program can be complied.
> If not so the program can not be complied by Dev-C++ and I am confused about that.
> I really want to know how to write the line correctly.
> Please give me an example.

As I have said, you need to cast &std::pow to a specific
type of function pointer to resolve the ambiguity.
I'll break this down further.
a) You need to cast. I assume that you know how
casts in C++ work. If not, look up static_cast
in your favorite elementary C++ text.
b) You need to know the function pointer type to cast to.
Do you know what a function pointer type looks like?
It's similar to a function declaration.
<return type> (*)(<argument types>)
for example, given the declaration
int foo(char);
the type of &foo is int(*)(char).
Since there are several overloads of std::pow,
you need to pick the one that is most appropriate.

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