Re: [sigc] templates and my problem
- From: Kjell Ahlstedt <kjell ahlstedt bredband net>
- To: Mohsen Pahlevanzadeh <mohsen pahlevanzadeh org>
- Cc: Libsigc++ <libsigc-list gnome org>
- Subject: Re: [sigc] templates and my problem
- Date: Wed, 01 Aug 2012 18:53:23 +0200
2012-08-01 16:45, Mohsen Pahlevanzadeh skrev:
Dear all,
I have 2 question: a. about the libsigc b. about (this) word and typeof
or decltype
I have NetworkSocket class and coded in main() func such as the
following:
///////////////////////////////////
NetworkSocket *oo = new NetworkSocket();
oo->ready.connect(sigc::ptr_fun(&NetworkSocket::createThread));
oo->run();
///////////////////////////////////////
Above code get the following error:
/////////////////
error: no matching function for call to ‘ptr_fun(bool (NetworkSocket::*)())’
////////////////
When i comment the above code , and put the following code in constructor :
//////////////////////////////////////
typeof(this) sig = new NetworkSocket();
sig->ready.connect(sigc::ptr_fun(createThread));
this->run();
////////////////////////////////////////
I get the following error:
////////////////////////////////
error: no matching function for call to ‘ptr_fun(<unresolved overloaded function type>)’
////////////////////////////////
So , i think g++ can't understand type of this reserverd word.And i don't understand no match call function.
Yours,
Mohsen
Is NetworkSocket::createThread() a static member function? If it's not
static, you must use sigc::mem_fun() instead of sigc::ptr_fun().
NetworkSocket *oo = new NetworkSocket();
oo->ready.connect(sigc::mem_fun(*oo, &NetworkSocket::createThread));
oo->run();
or
typeof(this) sig = new NetworkSocket();
sig->ready.connect(sigc::mem_fun(*this, &NetworkSocket::createThread));
// or mem_fun(*sig...?
this->run();
but here you have 2 NetworkSocket objects, *this and *sig. Is that what
you want? Should it be
ready.connect(sigc::mem_fun(*this, &NetworkSocket::createThread));
this->run();
What makes you suspect that g++ does not understand typeof(this)? You
don't mention any error message that contains 'typeof'.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]