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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:18:51+00:00 2026-06-06T00:18:51+00:00

I am not using boost libraries. How can i do this using STL? class

  • 0

I am not using boost libraries. How can i do this using STL?

class Files
{

private:
   bool isSame(FileID f1, FileId f2)
   { 
      if(f1.getId()==f2.getId())
        return true;
      return false;
   }

public:
   vector<FileId> mod_files;

    void update()
    {
      FildId f = getFileId();
      vector<FildId>::const_iterator found = find_if(mod_files.begin(), mod_files.end(),          ???);
    }

};

I would like to pass isSame as the third argument to find_if function, and bind “f” to the isSame’s second argument.

  • 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-06T00:18:52+00:00Added an answer on June 6, 2026 at 12:18 am

    In C++11 that’s simply:

    std::bind(&Files::isSame, this, f);
    

    In good old C++03 there is no mem_fun that takes 2 arguments, so you would have to do the binding on your own:

    class is_same_pred
    {
    public:
        // unary function typedefs
    
        explicit is_same_pred(Files& files, FileId f1) : _files(files), _f1(f1) {}
    
        bool operator()(FileId f2) const { return _files.isSame(_f1, f2); }
    
    private:
        Files& _files;
        FileId _f1;
    };
    

    Where isSame is accessible to is_same_pred, and later use it like this:

    is_same_pred(this, f);
    

    All that said and done, you would be better off defining isSame as a static or free-function:

    bool isSame(FileId f1, FileId f2){ ... }
    
    std::bind1st(std::ptr_fun(&isSame), f);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to install the Boost C++ libraries using these instructions . This
I must generate a random number using boost libraries, I use this code: boost::mt19937
Okay so I'm not using any session variables, rather my code looks like this:
[edit] I am NOT using jquery in this app. Looking for a way to
Is there some equivalent class for C++1x's std::unique_ptr in the boost libraries? The behavior
I have just started with using boost libraries. For one of our projects i
Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link
I'm quite new to using boost and I can't seem to find documentation anywhere
I would like to start using boost in an embedded environment. I can live
I am experiencing a crash while using the Boost.Spirit and Boost.Thread libraries in my

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.