Jump to content
  • Advertisement

Archived

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

genne

trouble using boost::bind

This topic is 5430 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

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

Share this post


Link to post
Share on other sites
Advertisement
Cast. Something like static_cast<const int& (Test::*)(int) const>(&Test::operator[]).

main''s return type isn''t void, btw.

Share this post


Link to post
Share on other sites

  • 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!