boost::bind problems with __cdecl and MSVC
Hello,
I have problems using wonderful boost::bind with __cdecl member
functions like the following:
#include
Daniel Boelzle wrote:
Hello,
I have problems using wonderful boost::bind with __cdecl member functions like the following:
#include
struct S { void __cdecl foo( int ); };
void bar() { S s; int const n = 5; boost::bind( &S::foo, &s, _1 )( n ); }
... error C2825: 'F::result_type': cannot form a qualified name ...
I am using MSVC Version 13.10.3077 and boost 1.32.0.
This can only happen if your default calling convention is something other than __cdecl. This is very rare and boost::bind does not provide explicit support for __cdecl, relying on it being the default. You can get around the restriction for non-member functions by using bind<void>, but for member functions, since mem_fn does not have __cdecl overloads, it can't be made to work with the current implementation.
Peter Dimov wrote:
Daniel Boelzle wrote:
Hello,
I have problems using wonderful boost::bind with __cdecl member functions like the following:
#include
struct S { void __cdecl foo( int ); }; <snip> This can only happen if your default calling convention is something other than __cdecl. This is very rare and boost::bind does not provide explicit support for __cdecl, relying on it being the default. <snip>
This is not correct. For non-static member functions the default calling convention is "thiscall" which is more efficient than "cdecl" (the "this" pointer is passed in a register, and the called function increments the return stack pointer over the arguments). Personally I don't see the point in changing the calling convention for a non-static member function. Ben.
participants (3)
-
Ben Hutchings
-
Daniel Boelzle
-
Peter Dimov