This topic is now archived and is closed to further replies.


trouble using boost::bind

Recommended Posts

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 {
  // ...

  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

Share this post

Link to post
Share on other sites