Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inherit from std::function, syntax and usage?

I don't understand the syntax when a functor inherits from std::function:

class do_sth : public function< any_type (another_type) >
{
    bool operator() (string s) {...}
};

What should I use as any_type and another_type? And can you give me an example of a beneficial usage of inheriting from std::function since I haven't understood it yet?

like image 885
SimonH Avatar asked Sep 17 '25 09:09

SimonH


1 Answers

You should use the return type of your operator () for any_type and the argument types for another_type. Then at least it fits.

But really, std::function is not meant to be inherited from, and doing so is probably a bad idea.

like image 174
Sebastian Redl Avatar answered Sep 18 '25 23:09

Sebastian Redl