# small conversion problem

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone :) im still having SMALL ( thx to you, big problem's are behing me :) ) i need to convert this :
cTexteManager::GetInstance().glPrint(xpos,ypos, txt.c_str() ) ;

into a boost::bind function . i tried this, but doesnt seems to work ( error saying taht my function doesnt take 4 args ... )
        DrawingList.Add(  boost::bind<void>( &cTexteManager::glPrint, cTexteManager::GetInstance(),xpos,ypos, txt.c_str() ) ) ;

just for information, im obviously NOT inside of the cTexteManager class ( singleton design pattern ) Any ideas? thx

##### Share on other sites
It looks like your GetInstance function returns a reference (my preference), so you should be passing the address of its return to boost bind as the second parameter.

In other words, change this:

...boost::bind<void>( &cTexteManager::glPrint, cTexteManager::GetInstance()...

to

...boost::bind<void>( &cTexteManager::glPrint, &cTexteManager::GetInstance()...

##### Share on other sites
I tried that : and i get this error :

error C2064: term does not evaluate to a function taking 4 arguments
class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments

##### Share on other sites
Hum in fact, this code alone does compile :

 boost::bind<void>( &cTexteManager::glPrint, &cTexteManager::GetInstance(),xpos,ypos, txt.c_str() ) ;

but i cannot add it to my vector ;/

std::vector< boost::function<void (void)>  > vec ;void cFunctionList::Add(boost::function<void (void)> func){	vec.push_back(func) ; }

##### Share on other sites
T_T i tried everything , i dont see where im going , maybe i need to change my vector ? but to what ?

bump

bump

##### Share on other sites
I'm not very familiarized with templates but try this:
typedef boost::function<void (void)> boost_function_void;std::vector<boost_function_void> vec ;

##### Share on other sites
HUm, i MAY be wrong, but isn't it the SAME exactly as what i've done :

std::vector< boost::function<void (void)>  > vec ;

##### Share on other sites
yes, but I've tried doing this without success:
CMyClass<CMyClass<int>> blah;

but using typedef it would work, like this:
typedef CMyClass<int> CMyClass_int;CMyClass<CMyClass_int> blah;

But I'm not even sure this is your problem and as I said before
I'm not very familiarized with templates, so don't trust me fully on this.

Hope I helped.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 14
• 13
• 14
• 69
• 22
• ### Forum Statistics

• Total Topics
632138
• Total Posts
3004319

×