I have a Visual Studio 2008 C++ application that does something like this:
template< typename Fcn >
inline void Bar( Fcn fcn ) // line 84
{
fcn();
};
template< typename Fcn >
inline void Foo( Fcn fcn )
{
// this works fine
Bar( fcn );
// this fails to compile
boost::bind( Bar, fcn )();
};
void main()
{
SYSTEM_POWER_STATUS_EX status = { 0 };
Foo( boost::bind( ::GetSystemPowerStatusEx, &status, true ) ); // line 160
}
*The call to GetSystemPowerStatusEx() is just for demonstration. Insert your favorite call there and the behavior is the same.
When I go to compile this, I get 84 errors. I won't post them all unless asked, but they start with this:
1>.\MyApp.cpp(99) : error C2896: 'boost::_bi::bind_t<_bi::dm_result<MT::* ,A1>::type,boost::_mfi::dm<M,T>,_bi::list_av_1<A1>::type> boost::bind(M T::* ,A1)' : cannot use function template 'void Bar(Fcn)' as a function argument
1> .\MyApp.cpp(84) : see declaration of 'Bar'
1> .\MyApp.cpp(160) : see reference to function template instantiation 'void Foo<boost::_bi::bind_t<R,F,L>>(Fcn)' being compiled
1> with
1> [
1> R=BOOL,
1> F=BOOL (__cdecl *)(PSYSTEM_POWER_STATUS_EX,BOOL),
1> L=boost::_bi::list2<boost::_bi::value<_SYSTEM_POWER_STATUS_EX *>,boost::_bi::value<bool>>,
1> Fcn=boost::_bi::bind_t<BOOL,BOOL (__cdecl *)(PSYSTEM_POWER_STATUS_EX,BOOL),boost::_bi::list2<boost::_bi::value<_SYSTEM_POWER_STATUS_EX *>,boost::_bi::value<bool>>>
1> ]
If anybody can point out what I may be doing wrong, I would appreciate it.
Thanks,
PaulH