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

  • SEARCH
  • Home
  • 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 8905457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:23:56+00:00 2026-06-15T02:23:56+00:00

Ran into a bit of an issue with std::bind when adding a placeholder My

  • 0

Ran into a bit of an issue with std::bind when adding a placeholder
My code is kind of big so I’ll just stick to the essentials

#define GETFUNC(a) (std::bind(&app::a, this, std::placeholders::_1))
class button{
button(<other parameters here>, std::function<void(int)>) { ... }
..
std::function<void(int)> onhover;
..
};

class app{
app(){
elements.push_back(buttonPtr( new button(<other parameters>, GETFUNC(onHover) );
..
typedef std::unique_ptr<button> buttonPtr;
std::vector<buttonPtr> elements;
..
void onHover(int i) {}
}

That bit of code fails at std::bind ( that much I got from the error log )
but works if I change:

  • all std::function<void(int)> to std::function<void()>
  • onHover(int i) to onHover()
  • std::bind(&app::a, this, std::placeholders::_1) to std::bind(&app::a, this)

Any thoughts on why this happens and how can I fix it?

  • 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-15T02:23:57+00:00Added an answer on June 15, 2026 at 2:23 am

    It’s working fine. Check this and look for differences to your code.

    #include <functional>
    #include <iostream>
    
    
    struct app
    {
      std::function<void (int)>
      get_func ()
      {
        return std::bind (&app::on_hover, this, std::placeholders::_1);
      }
    
      void on_hover (int v)
      {
        std::cout << "it works: " << v << std::endl;
      }
    };
    
    int
    main ()
    {
      app a;
    
      auto f = a.get_func ();
      f (5);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ran into a bit of an issue with some jQuery code, but in essence,
I've ran into a bit of an issue as I'd like two TextViews to
Trying to understand Ruby a bit better, I ran into this code surfing the
I have a bit complex to explain issue that I have ran into: I
I ran into a bit of trouble while trying to load an external HTML
Today I ran into something a bit weird. I used mini-profiler to see the
Recently I ran into a very strange issue: touching the screen of the iPhone
While converting from RSpec to Minitest I ran into a slight issue that Google
There's a bit of code which writes data to a MemoryStream object directly into
I recently ran into an odd issue where I'd get a const_iterator instead of

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.