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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:33:13+00:00 2026-05-20T16:33:13+00:00

I can’t figure out whats wrong with the code here, so I was hopinh

  • 0

I can’t figure out whats wrong with the code here, so I was hopinh someone could help me out:

In a header file, I define the following functions

void GenLiveVar(const instr_ptr instr, std::vector<ResultBase*> &list);
void KillLiveVar(const instr_ptr instr, std::vector<ResultBase*> &list);

In a class header file, I define this typedef:

typedef boost::function<void(instr_ptr, std::vector<ResultBase*>) > GenFunction;

inside the class, I have two instances of GenFunction

GenFunction Gen;
GenFunction Kill;

And I assign into them as follows

void DataFlowSolver::SetGenFunction(GenFunction &func)
{
    Gen = func;
}

void DataFlowSolver::SetKillFunction(GenFunction &func)
{
    Kill = func;
}

later in my program, I assign to gen as follows:

blockSolver.SetGenFunction(GenLiveVar);

where GenLiveVar is the function mentioned earlier and blockSolver is an instance of the class holding the Gen/Kill. Inside blockSolver, I do the following:

std::vector<ResultBase*> genList;
Gen(currentBlock->GetInstrPtr(i), &genList);

and GetInstrPtr is defined as const instr_ptr GetInstrPtr(int index);

It generates the follwoing error (sorry for length)

    no match for call to '(GenFunction) (const instr_ptr, std::vector<ResultBase*, std::allocator<ResultBase*> >*)'
    /nfs/ug/homes-2/r/rileyjon/ece540/Final/boost/function/function_template.hpp:1007: 
note: candidates are: typename boost::function2<R, T1, T2>::result_type boost::function2<R, T1, T2>::operator()(T0, T1) const [with R = void, T0 = boost::shared_ptr<Instruction>, 
T1 = std::vector<ResultBase*, std::allocator<ResultBase*> >

]

I dont really understand why this is a problem: the types are definitely the same. Some help would be appreciated. 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-05-20T16:33:14+00:00Added an answer on May 20, 2026 at 4:33 pm

    The types are definitely not the same.

    The argument you are passing is of type std::vector<ResultBase*>* (a pointer):

    Gen(currentBlock->GetInstrPtr(i), &genList);
                                      ^
    

    The corresponding parameter is of type std::vector<ResultBase*> (a value):

    boost::function<void(instr_ptr, std::vector<ResultBase*>)>
                                                           ^
    

    Also note the mismatch in parameter types between the boost::function, which takes the second argument by value, and the two functions you assign to it, which take their second arguments by reference. This probably won’t give you the behavior you expect.

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

Sidebar

Related Questions

can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can't figure out how to do this in a pretty way : I have
Can i get the source code for a WAMP stack installer somewhere? Any help
Can anyone help me trying to find out why this doesn't work. The brushes
Can someone help me? I am trying to do something like the following: #include
Can someone explain the usage of the dollar sign here.. var updateProgressDiv = $get('updateProgressDiv');
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can you cast a List<int> to List<string> somehow? I know I could loop through
Can anyone recommend a good library for generating an audio file, such as mp3,
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.