Skip to main content
gamedev.net
🔒 Locked

trouble using boost::bind

Started by genne Aug 9, 2003 at 4:58 PM 1 replies 350+ views
Original Post
genne
genne
Let''s say you''re having two overloaded functions with the same arguments, but with different const declarations - how do you tell boost::bind which one to use? For instance:
class Test {
  // ...

public:
  int &operator[]( int index ) { /* ... */ }
  const int &operator[]( int index ) const { /* ... */ }
};

void main() {
  Test test;
  // ...

  cout << boost::bind( &Test::operator[], boost::cref( test ), 0 )();
}
The last line will result in "error C2914: ''bind'' : cannot deduce template argument as function argument is ambiguous". Though, if you remove one of the overloaded functions, so you''re left with one, it will compile just fine. Anyone knows how to solve this? How to tell boost::bind which overloaded function you wan''t to use? Thx in advance! -Genne
DrPizza
DrPizza
Cast. Something like static_cast<const int& (Test::*)(int) const>(&Test::operator[]).

main''s return type isn''t void, btw.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/
genne
genne
Aah, thx alot! It works just fine now!

Uhm, not sure why i made main return void..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.