Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:20:25+00:00 2026-06-01T17:20:25+00:00

I have two overloaded member functions with the following signatures: class MyClass { void

  • 0

I have two overloaded member functions with the following signatures:

class MyClass
{
    void f(int, int, int);
    void f(int, int, int, double);
};

I am using boost::bind as follows:

boost::bind(&MyClass::f, _1, 1, 2, 3); // _1 is a placeholder for the implicit parameter

My problem is actually that there is no problem. According to boost::bind documentation (at http://www.boost.org/doc/libs/1_49_0/libs/bind/bind.html#err_overloaded) this should “usually” result in an error, and I should need to cast to the function pointer type. However my code compiles without error, and appears to run as expected.

The example given in the documentation is one where the only difference in the overloaded functions is that one is const while the other is not. My guess therefore is that I do not have a problem because the compiler can tell the difference between the two overloaded functions due to the fact that the number (and types) of arguments is different, whereas in the documentation’s example there is no way for the compiler to tell which version you intend simply from the arguments passed to boost::bind. On the other hand, I am skeptical of my guess because I question how the compiler knows that the last 3 arguments passed to boost::bind in my example are linked to the function pointer in the first argument (and therefore form part of its signature) – it seems to me that that is an internal matter for boost::bind which the compiler should have no knowledge of.

Neither the documentation nor any other advice I can find upon googling this issue specify that there is only an issue with overloaded functions which have the same argument types. So, I would be grateful if anyone could confirm that my guess is correct (and by implication, why my skepticism is wrong), before I begin relying on my code under the (possibly false) assumption that it is valid. My concern is that the compiler is simply choosing which function to bind based on reasoning which I did not intend e.g. picking the first one it comes across.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:20:26+00:00Added an answer on June 1, 2026 at 5:20 pm

    If there is only one choose that is semantically correct, then you are fine (like in your example). If there are more, don’t guess what it will pick, pick for it (like in boost’s example).
    Since bind, like everything else in c++, is strongly typed, the compiler can’t just shrink the function or something so it will not make impossible chooses like picking the first in your example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I have these two overloaded functions. public static void Main(string[]args) { int
I have two functions that I have overloaded for my debug class: template<class IteratorT>
I have a class which has two overloaded functions. How do I export it
I have two overloaded methods, one with an optional parameter. void foo(string a) {
I would like to call a member through lambda::bind. Unfortunately I have got two
Suppose I have the following class hierarchy: class A { int foo; virtual ~A()
I have a class that has two functions, both of which take a different
I have an issue, i need to add two class members using a operator
I noticed this the other day, say you have two overloaded methods: public void
Suppose I have two versions of operator-> (overloaded on const) in a base class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.