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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:31:17+00:00 2026-05-12T11:31:17+00:00

In the past I’ve used the bind1st and bind2nd functions in order to do

  • 0

In the past I’ve used the bind1st and bind2nd functions in order to do straight forward operations on STL containers. I now have a container of MyBase class pointers that are for simplicities sake the following:

class X
{
public:
    std::string getName() const;
};

I want to call the following static function using for_each and binding both the 1st and 2nd parameters as such:

StaticFuncClass::doSomething(ptr->getName(), funcReturningString() );

How would I use for_each and bind both parameters of this function?

I’m looking for something along the lines of:

for_each(ctr.begin(), ctr.end(), 
         bind2Args(StaticFuncClass::doSomething(), 
                   mem_fun(&X::getName), 
                   funcReturningString());

I see Boost offers a bind function of its own that looks like something that would be of use here, but what is the STL solution?

Thanks in advance for your responses.

  • 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-12T11:31:17+00:00Added an answer on May 12, 2026 at 11:31 am

    A reliable fallback when the bind-syntax gets too weird is to define your own functor:

    struct callDoSomething {
      void operator()(const X* x){
        StaticFuncClass::doSomething(x->getName(), funcReturningString());
      }
    };
    
    for_each(ctr.begin(), ctr.end(), callDoSomething());
    

    This is more or less what the bind functions do behind the scenes anyway.

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

Sidebar

Related Questions

in past I have used fbml rendering but now there is to many update
In the past I have used MAPISendMail to launch Outlook (or whatever the desired
In the past, I've used the runas commandline to launch another instance if IE
In past i have worked with JQuery 1.2 vsdoc file which generates intellisense for
In past years I have learned the most important languages for web development (CSS,
For the past couple of months I have tried to figure out a pattern
For the past day I have been trying to figure out how to change
In past couple of days, I have read about quite a lot about dependency
In the past, I used swiftsuspenders that is an actionscript 3 IoC controller. Basically
In the past I have seem a couple of people say C+ (with just

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.