Jump to content
• Advertisement

Public Group

# std::mem_fun, can't deduce template argument

This topic is 3821 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Here is the code:
class CTest
{
std::list<int> List;

public:
bool __stdcall Functor(int A)
{
//Do some stuff
return true;
};

void __stdcall Excute
{
std::for_each(List.begin(), List.end(),
std::bind1st(std::mem_fun(&CTest::Functor), this));
};
};


When compiling, it gives an error: could not deduce template argument for '_Result (__thiscall _Ty::* )(_Arg) const' from 'bool (__stdcall CTest::* )(int)'

#### Share this post

##### Share on other sites
Advertisement
If you read the error it says it cannot perform a conversion between types, and if you look closely at the flagged types they differ only in calling convention. Namely __thiscall and __stdcall. It seems that calling convention plays a part in a functions type.

If you don't specify the calling convention that will make the error go away (there should be no reason for you to explicitly choose it anyways).

#### Share this post

##### Share on other sites
Why on in the name of all that is holy are you trying to specify __stdcall calling convention explicitly? Member functions - the ones you define inside a class which are not static - are supposed to be __thiscall. Hint: it's named after the keyword "this". You know, the bit you want to pass to std::bind1st.

It looks like you've mixed up two attempts at fixing the same problem, one of which is correct (setting up std::bind1st and std::mem_fun logic) and one of which is an ungodly WTF (trying to force a calling convention that doesn't actually work for those functions).

By the way, why does Functor return anything?

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Now

• 19
• 10
• 19
• 14
• 19
• Advertisement
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!