Re: [Boost-users] A question on overloaded function? Can anyone with kindness help me?

I do not understand the sentence: Ignore the "conversion to unsigned int" part. As you know, I am a new comer and quite puzzled about that. Does that mean to change the complier enviroment? Can you give me an example? Thank you for your kindness. 在2009-07-02,"Steven Watanabe" <watanabesj@gmail.com> 写道:
AMDG
fmingu wrote:
But how can I change the expression to be legal and usable? bind(&std::pow,constant(-1),bind(&IIPrimemap::size,var(primemapvec))); I tried : bind(&std::pow,constant(-1.0),bind<int>(&IIPrimemap::size,var(primemapvec))); and bind(&std::pow,constant(-1.0),ret<int>(bind(&IIPrimemap::size,var(primemapvec)))); even bind(&std::pow,constant(-1.0),ll_dynamic_cast<int>(bind(&IIPrimemap::size,var(primemapvec)))); But the complier told me that: cannot resolve overloaded function `pow' based on conversion to type `unsigned int'
Ignore the "conversion to unsigned int" part. The compiler doesn't know how to handle std::pow and gets itself confused. The problem is &std::pow, not the inner bind expression.
I do not know how to solve now. Can anyone with kindness help me?
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 Christ, Steven Watanabe
200万种商品,最低价格,疯狂诱惑你

AMDG fmingu wrote:
I do not understand the sentence: Ignore the "conversion to unsigned int" part. As you know, I am a new comer and quite puzzled about that. Does that mean to change the complier enviroment? Can you give me an example?
I meant to say the the compiler's mentioning unsigned int is nonsense. That part of the error message is useless. Don't pay any attention to it. This part of my previous message is not particularly important.
��2009-07-02��"Steven Watanabe" <watanabesj@gmail.com> ���
fmingu wrote:
But the complier told me that: cannot resolve overloaded function `pow' based on conversion to type `unsigned int'
Ignore the "conversion to unsigned int" part. The compiler doesn't know how to handle std::pow and gets itself confused. The problem is &std::pow, not the inner bind expression.
In Christ, Steven Watanabe

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. Thanks a lot. 在2009-07-02,"Steven Watanabe" <watanabesj@gmail.com> 写道:
AMDG
fmingu wrote:
I do not understand the sentence: Ignore the "conversion to unsigned int" part. As you know, I am a new comer and quite puzzled about that. Does that mean to change the complier enviroment? Can you give me an example?
I meant to say the the compiler's mentioning unsigned int is nonsense. That part of the error message is useless. Don't pay any attention to it. This part of my previous message is not particularly important.
在2009-07-02,"Steven Watanabe" <watanabesj@gmail.com> 写道:
fmingu wrote:
But the complier told me that: cannot resolve overloaded function `pow' based on conversion to type `unsigned int'
Ignore the "conversion to unsigned int" part. The compiler doesn't know how to handle std::pow and gets itself confused. The problem is &std::pow, not the inner bind expression.
In Christ, Steven Watanabe

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

According to your suggestion,I tried to write: bind(static_cast<pair<IIPrimemap::iterator,bool> (*)(const IIPrimemap::value_type&)> (IIPrimemap::insert), bind(&make_pair<int,int>,_1,constant(1))); where typedef std::map<int, int> IIPrimemap; IIPrimemap primemapvec; but the complier told me that: invalid static_cast from type `<unknown type>' to type ` std::pair<std::_Rb_tree_iterator<std::pair<const int, int>, std::pair<const int, int>&, std::pair<const int, int>*>, bool> (*)(const std::pair<const int, int>&)' Can you tell me why? Thanks. 在2009-07-02,"Steven Watanabe" <watanabesj@gmail.com> 写道:
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

AMDG fmingu wrote:
According to your suggestion,I tried to write: bind(static_cast<pair<IIPrimemap::iterator,bool> (*)(const IIPrimemap::value_type&)> (IIPrimemap::insert), bind(&make_pair<int,int>,_1,constant(1))); where typedef std::map<int, int> IIPrimemap; IIPrimemap primemapvec;
but the complier told me that: invalid static_cast from type `<unknown type>' to type ` std::pair<std::_Rb_tree_iterator<std::pair<const int, int>, std::pair<const int, int>&, std::pair<const int, int>*>, bool> (*)(const std::pair<const int, int>&)' Can you tell me why?
IIPrimemap::insert is a member function. The syntax for a pointer to a member function is <return type> (<class name>::*)(<args>) In Christ, Steven Watanabe
participants (2)
-
fmingu
-
Steven Watanabe