# small conversion problem

This topic is 4710 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.

##### Share on other sites
I tried ...didnt worked , thx anyway .

I think i will need a new way of doing what im doing .

( i still just need to be aable to add some functions ( they all return void, but all takes different argument types ) to a container i can easyli "parse" .

hummmm :p

##### Share on other sites
Quote:
 Original post by Kamikaze15yes, but I've tried doing this without success:CMyClass> blah;

That's because the >> in <CMyClass<int>> get's interpreted as operator>>. You need to put a space between them, like so:
<CMyClass<int> >

There are plans to change this so it's not an issue in the next version of c++.

##### Share on other sites
Humm, that makes sense, thanks for clearing that up to me.