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 6583467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:24:48+00:00 2026-05-25T16:24:48+00:00

Is there way to do something like this (MS VS 2008)? boost::bind mybinder =

  • 0

Is there way to do something like this (MS VS 2008)?

boost::bind mybinder = boost::bind(/*something is binded here*/);
mybinder(/*parameters here*/); // <--- first call
mybinder(/*another parameters here*/); // <--- one more call

I tried

int foo(int){return 0;}

boost::bind<int(*)(int)> a = boost::bind(f, _1);

but it doesn’t work.

  • 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-05-25T16:24:48+00:00Added an answer on May 25, 2026 at 4:24 pm

    The bind returns unspecified type, so you can’t directly create a variable of the type. There is however a type template boost::function that is constructible for any function or functor type. So:

    boost::function<int(int)> a = boost::bind(f, _1);
    

    should do the trick. Plus if you are not binding any values, only placeholders, you can do without the bind altogether, because function is constructible from function pointers too. So:

    boost::function<int(int)> a = &f;
    

    should work as long as f is int f(int). The type made it to C++11 as std::function to be used with C++11 closures (and bind, which was also accepted):

    std::function<int(int)> a = [](int i)->int { return f(i, 42); }
    

    note, that for directly calling it in C++11, the new use of auto is easier:

    auto a = [](int i)->int { return f(i, 42); }
    

    but if you want to pass it around, std::function still comes in handy.

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

Sidebar

Related Questions

In Ant is there any way to do something like this: <arguments id=arg-list> <arg
Is there a way in java to do something like this: void fnc(void Reference_to_other_func());
Is there any way to crate nested union types in F#? Something like this
Is there a way to obtain something like a dictionary of all key-value pairs
Is there a way to pass null arguments to C# methods (something like null
is there a way in Excel to have a formula that does something like
Is there a way to execute code after each Terminal? So that something like
Is there any way to write a valid header/link/image? Something like <a href=index.html><h1 id=logo>Company
is there a way to 'break' out of a groovy closure. maybe something like
Is there a way to make a class function unoverriddable? Something like Java's final

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.