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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:32:44+00:00 2026-05-10T23:32:44+00:00

The VS2008 SP1 documentation talks about std::tr1::mem_fun . So why, when I try and

  • 0

The VS2008 SP1 documentation talks about std::tr1::mem_fun.

So why, when I try and use std::tr1::mem_fun, why do I get this compile error?:

'mem_fun' : is not a member of 'std::tr1' 

At the same time, I can use std::tr1::function without problems.

Here is the sample code I am trying to compile, which is supposed to call TakesInt on an instance of Test, via a function<void (int)>:

#include 'stdafx.h' #include <iostream> #include <functional> #include <memory>  struct Test { void TakesInt(int i) { std::cout << i; } };  void _tmain()  {     Test* t = new Test();      //error C2039: 'mem_fun' : is not a member of 'std::tr1'     std::tr1::function<void (int)> f =         std::tr1::bind(std::tr1::mem_fun(&Test::TakesInt), t);     f(2); } 

I’m trying to use the tr1 version of mem_fun, because when using std::mem_fun my code doesn’t compile either! I can’t tell from the compiler error whether the problem is with my code or whether it would be fixed by using tr1’s mem_fun. That’s C++ compiler errors for you (or maybe it’s just me!).


Update: Right. The answer is to spell it correctly as mem_fn!

However when I fix that, the code still doesn’t compile.

Here’s the compiler error:

error C2562:  'std::tr1::_Callable_obj<_Ty,_Indirect>::_ApplyX' :   'void' function returning a value 
  • 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. 2026-05-10T23:32:45+00:00Added an answer on May 10, 2026 at 11:32 pm

    Change it to this:

    std::tr1::function<void (int)> f =     std::tr1::bind(std::tr1::mem_fn(&Test::TakesInt), t, std::tr1::placeholders::_1); f(2); 

    The binder requires the int argument. So you have to give it a placeholder which stands for the integer argument that the generated function object needs.

    Btw: I’m not sure whether you already know this or not. But you don’t need that mem_fn for this. Just change it to

    std::tr1::function<void (int)> f =     std::tr1::bind(&Test::TakesInt, t, std::tr1::placeholders::_1); f(2); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can try RESTORE HEADERONLY on your backup file, as… May 11, 2026 at 9:47 pm
  • Editorial Team
    Editorial Team added an answer I'm not aware of that function, or anything similar, in… May 11, 2026 at 9:47 pm
  • Editorial Team
    Editorial Team added an answer Seems the more I learn things, the more I see… May 11, 2026 at 9:47 pm

Related Questions

Has the $format parameter been removed with the VS2008 SP1 release of ADO.NET Data
I've just upgraded a native C++ project from VS2005-SP1 to VS2008-SP1 The first thing
When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems
Alright, after doing a ton of research and trying almost every managed CPP Redist

Trending Tags

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

Top Members

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.