Jump to content
  • Advertisement


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


trouble using boost::bind

This topic is 5609 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 {
  // ...

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!