I have declared:
class aaa {
public:
static std::queue<QPair<void (*)( ... ), int> > m_commands;
static int bbb();
static void ccc(...);
};
and in bbb() method I wrote:
int aaa::bbb() {
m_commands.push( qMakePair( aaa::ccc, 0 ) );
}
but it complains about:
error C2664: 'void std::queue<_Ty>::push(QPair<T1,T2> &&)' : cannot convert parameter 1 from 'QPair<T1,T2>' to 'QPair<T1,T2> &&'
why? When I had function like that:
void reg( void ( *invoker )( ... ), int args ) {
m_commands.push( qMakePair( invoker, args ) );
}
I could easily send to the above function a static function this way:
reg( aaa::ccc, 0 );
qMakePair( aaa::ccc, 0 )is (presumably) returning a value of typeQPair<void (*)(), int>, since it doesn’t know that you want a value of typeQPair<void (*)( ... ), int>. Invoke it explicitly asqMakePair<void (*)( ... ), int>( aaa::ccc, 0 )orreinterpret_castaaa::cccto the desired function pointer type.Not to mention that this is (almost certainly) illegal, as
aaa::cccdoes not have the correct signature and cannot be invoked through the function pointer type you’re using.