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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:12:22+00:00 2026-06-13T11:12:22+00:00

I am trying to create a functor like so: struct STFRandomTreeFunction { typedef double

  • 0

I am trying to create a functor like so:

struct STFRandomTreeFunction
{
    typedef double (*function_ptr)(const TrainingDataPoint& data, boost::unordered_map<std::string, cv::Mat>& preloaded_images);
};


struct STFRandomTreeFunctor
{
private:
    boost::unordered_map<std::string, cv::Mat> *image_cache;
    STFRandomTreeFunction::function_ptr function;
    std::string function_id;

public:
    STFRandomTreeFunctor(boost::unordered_map<std::string, cv::Mat>& cache, STFRandomTreeFunction::function_ptr function_ptr, std::string function_id){
        image_cache = &cache;
        this->function = function;
        this->function_id = function_id;
    }

    std::string get_function_id(){
        return function_id;
    }

    double operator()(const TrainingDataPoint& data_point){
        return function(data_point, *image_cache);
    }
};

And am trying to run the following code:

double something(const TrainingDataPoint& a, unordered_map<string, Mat>& cache){
    return 5;
}


int main(int argc, char* argv[]) {

    unordered_map<string, Mat> cache;

    STFRandomTreeFunctor functor = STFRandomTreeFunctor(cache, something, "id");

    TrainingDataPoint d = TrainingDataPoint(1,2,"", ImagePoint(1,2), ImagePoint(1,2), "");

    double value  = functor(d);

    cout << "Value is " << value << endl;
}

However, I get no output. It appears as though some exception is throwing however eclipse is not showing me one but just showing that the program has terminated.

Any ideas?

  • 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-13T11:12:23+00:00Added an answer on June 13, 2026 at 11:12 am

    In the constructor of STFRandomTreeFunctor

    this->function = function;
    

    That’s self assignment. I assume you meant to do this:

    this->function = function_ptr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a packaged task with a functor like this: Worker w(someString,
I'm trying to create a thread class that executes a functor from an adapter.
All, I am trying create a 'to & fro' animation using jquery animate &
I am trying create a layout. There are several inner layouts that should like
I'm trying to create a std::unordered_map, using a user-defined hash function and equality predicate,
I'm trying create a simple audio stream server like a concept proof, but I'm
I'm trying to create a functor that returns a shared_ptr by calling std::bind on
I am trying create a data.frame from which to create a graph. I have
I've been trying create this simple ish to-do list web app using JavaScript &
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can

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.