Jump to content
  • Advertisement
Sign in to follow this  
Ey-Lord

small conversion problem

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 ?

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!