Reputation: 2002
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 );
Upvotes: 3
Views: 422
Reputation: 157354
qMakePair( aaa::ccc, 0 )
is (presumably) returning a value of type QPair<void (*)(), int>
, since it doesn't know that you want a value of type QPair<void (*)( ... ), int>
. Invoke it explicitly as qMakePair<void (*)( ... ), int>( aaa::ccc, 0 )
or reinterpret_cast
aaa::ccc
to the desired function pointer type.
Not to mention that this is (almost certainly) illegal, as aaa::ccc
does not have the correct signature and cannot be invoked through the function pointer type you're using.
Upvotes: 1