Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:23:30+00:00 2026-06-14T05:23:30+00:00

How does one can use std::bind (not boost::bind) on __stdcall function or is it

  • 0

How does one can use std::bind (not boost::bind) on __stdcall function or is it even possible in current implementation?
When i try to compile following example:

std::function<LRESULT __stdcall(int, WPARAM, LPARAM)> func;
func = std::bind(&EventListener::myhook, this, std::placeholders::_1, 
                 std::placeholders::_2, std::placeholders::_3);

or same but with declaring func as:

std::function<LRESULT(int, WPARAM, LPARAM> func;

Gives me strange build output (which i included below). There is a very sick way to make it compile:

decltype(std::bind(&EventListener::myhook, nullptr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))* HookCallbackPointer;
    HookCallbackPointer proc;

proc = reinterpret_cast<HookCallbackPointer>
    (&std::bind(&EventListener::myhook, this,
                std::placeholders::_1,
                std::placeholders::_2,
                std::placeholders::_3));

But it won’t let me call function like this (*proc)(0,0,0);. Which is sad.
All this happens just because that func – myhook – declared as __stdcall. Offcourse i can just write a dirty assembly hack that will push 4 dwords at the end of func and this will “make” it __stdcall, but i’m not quite sure about this and also this is even more sicker way.

1>D:\bin\Visual Studio\VC\include\xrefwrap(431): error C2440: 'return' : cannot convert from 'std::_Do_call_ret<_Forced,_Ret,_Funx,_Btuple,_Ftuple>::type' to 'LRESULT'
1>          with
1>          [
1>              _Forced=false,
1>              _Ret=void,
1>              _Funx=__w64 long (__stdcall EventListener::* )(int,WPARAM,LPARAM),
1>              _Btuple=std::tuple<EventListener *,std::_Ph<1>,std::_Ph<2>,std::_Ph<3>>,
1>              _Ftuple=std::tuple<int &,WPARAM &,LPARAM &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          Expressions of type void cannot be converted to other types
1>          D:\bin\Visual Studio\VC\include\functional(239) : see reference to function template instantiation '_Ret std::_Callable_obj<_Ty>::_ApplyX<_Rx,int,__w64 unsigned int,__w64 long>(_V0_t &&,_V1_t &&,_V2_t &&)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Rx=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(239) : see reference to function template instantiation '_Ret std::_Callable_obj<_Ty>::_ApplyX<_Rx,int,__w64 unsigned int,__w64 long>(_V0_t &&,_V1_t &&,_V2_t &&)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Rx=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(239) : while compiling class template member function 'LRESULT std::_Func_impl<_Callable,_Alloc,_Rx,_V0_t,_V1_t,_V2_t>::_Do_call(_V0_t &&,_V1_t &&,_V2_t &&)'
1>          with
1>          [
1>              _Callable=_MyWrapper,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>,
1>              _Rx=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(516) : see reference to class template instantiation 'std::_Func_impl<_Callable,_Alloc,_Rx,_V0_t,_V1_t,_V2_t>' being compiled
1>          with
1>          [
1>              _Callable=_MyWrapper,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>,
1>              _Rx=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(516) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(516) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(516) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(516) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Alloc=std::allocator<std::_Func_class<LRESULT,int,WPARAM,LPARAM>>
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(692) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          D:\bin\Visual Studio\VC\include\functional(692) : see reference to function template instantiation 'void std::_Func_class<_Ret,_V0_t,_V1_t,_V2_t>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=LRESULT,
1>              _V0_t=int,
1>              _V1_t=WPARAM,
1>              _V2_t=LPARAM,
1>              _Ty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>,
1>              _Fty=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          main.cpp(27) : see reference to function template instantiation 'std::function<_Fty> &std::function<_Fty>::operator =<std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fty=LRESULT (int,WPARAM,LPARAM),
1>              _Forced=false,
1>              _Ret=void,
1>              _Fun=LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),
1>              _V0_t=EventListener *const ,
1>              _V1_t=std::_Ph<1> &,
1>              _V2_t=std::_Ph<2> &,
1>              _V3_t=std::_Ph<3> &,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fx=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
1>          main.cpp(27) : see reference to function template instantiation 'std::function<_Fty> &std::function<_Fty>::operator =<std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fty=LRESULT (int,WPARAM,LPARAM),
1>              _Forced=false,
1>              _Ret=void,
1>              _Fun=LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),
1>              _V0_t=EventListener *const ,
1>              _V1_t=std::_Ph<1> &,
1>              _V2_t=std::_Ph<2> &,
1>              _V3_t=std::_Ph<3> &,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fx=std::_Bind<false,void,LRESULT (__stdcall EventListener::* )(int,WPARAM,LPARAM),EventListener *const ,std::_Ph<1> &,std::_Ph<2> &,std::_Ph<3> &,std::_Nil,std::_Nil,std::_Nil>
1>          ]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:23:31+00:00Added an answer on June 14, 2026 at 5:23 am

    In current VS 2012 its not possible and anyway not applicable as solution to this problem.
    The idea was to bind member function and use it as Hook-procedure. That is not possible, as David Rodriguez and R. Martinho Fernandes (in chat – lounge-C++) mentioned, because std::bind produces object, not function and thus it’s result can’t be passed as argument to SetWindowsHookEx.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one build a function that can set an arbitrary value within a
Maybe the worst type of error message that one can see. Does not mean
How does one use rm to delete a file named '--help'? When I try,
does any one know of any good countdown timer's for flash which i can
Can any one tell what does below given lines means? The lines below are
Please can some one briefly tell me with example what does the means of
Can any one tell me? what does following means in ruby program: obj =
When using the new function declarator syntax and decltype , how does one access
Does anyone know where I can find an implimentation that wraps a std::map and
I can't use shared_ptr in my project, no boost :( So, I'm having a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.