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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:30:23+00:00 2026-06-18T04:30:23+00:00

This is how I have my code setup: class SomeClass { public: std::function<void()> someFunction;

  • 0

This is how I have my code setup:

class SomeClass
{
public:
    std::function<void()> someFunction;
}

AnotherClass.h

class AnotherClass
{
public:
    void anotherFunction();
    void yetAnotherFunction();
    SomeClass someClass;
}

AnotherClass.cpp

void AnotherClass::anotherFunction()
{
    std::cout << "triggerd" << std::endl;
}

void AnotherClass::yetAnotherFunction()
{
    someClass.someFunction = &AnotherClass::anotherFunction; //here
}

This resulted in a compile time error: error C2664: 'std::_Func_class<_Ret>::_Set' : cannot convert parameter 1 from '_Myimpl *' to 'std::_Func_base<_Rx> *' After some research I found that this is a bug from VS2012 (source). So I changed the line labeled “here” to someClass.someFunction = std::mem_fn(&AnotherClass::anotherFunction); just like the solution says in the link. However, now this results in another compile time error: error C2562: 'std::_Callable_obj<_Ty>::_ApplyX' : 'void' function returning a value. So from the research I’ve found on that error, it means that there is a function declared as void returning a value. This is where I’m stuck because I’m 100% sure I don’t have any functions returning a value that shouldn’t be plus I didn’t get this error before changing the line labeled “here”. I not sure if this is another bug in VS2012 but the error does say: std::_Callable_obj<_Ty>::_ApplyX which is obviously not my function.

Does anybody have any information on why this is happening and how I can resolve it?

Thanks.

  • 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-18T04:30:24+00:00Added an answer on June 18, 2026 at 4:30 am

    You are assigning a non-static member function to a function object that expects something returning void and taking no arguments. A non-static member function has an implicit first parameter, which in this case would be of type AnotherClass*. You need an AnotherClass instance to bind to the member function.

    In your case, you can bind it to the this pointer:

    void AnotherClass::yetAnotherFunction()
    {
        someClass.someFunction = std::bind(&AnotherClass::anotherFunction, this);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code in actions.class.php public function executeListmatches(sfWebRequest $request) { $form_values = $request->getParameter('match_form',
I have this simple java code: public class AnAgent extends Agent { protected void
I have the following code: [SetUp] public void SetMeUp() { Mapper.CreateMap<SourceObject, DestinationObject>(); } [Test]
Lets say I have the following code: Mocked object class public class SomeClass {
I Have something similar to this setup: public class Base { public String getApple()
These are my testcases class Mother { @Before public void setUp() { if (!this.getClass().isAnnotatedWith(Version20))
Let's say I have a user class setup with validation like this: [MetadataType(typeof(ssUserMetaData))] public
I have downloaded this code from developer.android public class SpinnerTestActivity extends ActivityInstrumentationTestCase2<SpinnerActivity> { private
I have the following code class SomeClass def initialize(opts) if opts[:should_load] load else setup(opts[:path])
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);

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.