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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:56:12+00:00 2026-05-13T23:56:12+00:00

I have need for a function pointer that takes two arguments and returns a

  • 0

I have need for a function pointer that takes two arguments and returns a string.

I would like to pass an adapter that wraps a function that takes one argument, and returns the string (i.e. discard one of the arguments).

I can trivially build my own adapter, that takes the 2 arguments, calls the wrapped function passing just the one argument through.

But I’d much rather have a simple way to create an adapter on the fly, if there is an easy way to do so in C++/boost?

Here’s some details to make this a bit more concrete:

typedef boost::function<CString (int,int)> TooltipTextFn;

class MyCtrl
{
public:
    MyCtrl(TooltipTextFn callback = boost::bind(&MyCtrl::GetCellText, this, _1, _2)) : m_callback(callback) { }

    // QUESTION: how to trivially wrapper GetRowText to conform to TooltipTextFn by just discarding _2 ?!
    void UseRowText() { m_callback = boost::bind(&MyCtrl::GetRowText, this, _1, ??); }

private:

    CString GetCellText(int row, int column);
    CString GetRowText(int row);

    TooltipTextFn   m_callback;
}

Obviously, I can supply a member that adapts GetRowText to take two arguments and only passes the first to GetRowText() itself.

But is there already a boost binder / adapter that lets me do that?

  • 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-13T23:56:12+00:00Added an answer on May 13, 2026 at 11:56 pm

    By only providing _1, it will ignore the 2nd parameter given to m_callback and call MyCtrl::GetRowText with one int parameter.

    void UseRowText() { m_callback = boost::bind(&MyCtrl::GetRowText, this, _1); }
    

    On the other hand,

    void UseRowText() { m_callback = boost::bind(&MyCtrl::GetRowText, this, _2); }
    

    is also valid, where we send the 2nd parameter passed to m_callback into the 1st parameter of MyCtrl::GetRowText.

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

Sidebar

Ask A Question

Stats

  • Questions 509k
  • Answers 509k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This seems to fix my problem: url = '%s%s/?api_key=%s&method=%s&%s'% \… May 16, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer You can do it using the scrollTop method on DOM… May 16, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer It's a little hard to understand what you're after, but… May 16, 2026 at 4:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Suppose I have a C++ class like so: class A { public: A() {
I'm currently self-studying C for mastering an university project. In that project we have
This is a little contrived, but say I have a class interface like this:
I need to write a function which could create any type object. It receives
I've got a UL of items using jQuery UI that I have drag and
I have a string buffer: b = create_string_buffer(numb) where numb is a number of
I have a utility that compares a source and destination file date/time. This works
I got a weird problem. I have a program that (does many things but
I'm developing a game and I need to find a way of getting the
I have a multithreaded C++ application which holds a complex data structure in memory

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.