Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    Is void function1(std::function<void(int, int)>) correct? Commented Apr 9, 2015 at 1:51
  • 4
    You need to give the function argument a variable name and then the variable name is what you actually pass. So: void function1(std::function<void(int, int)> functionToCall) and then functionToCall(1,1);. I tried to edit the answer but someone rejected it as not making any sense for some reason. We'll see if it gets upvoted at some point. Commented Apr 9, 2015 at 5:52
  • 1
    @DorkyEngineer That's pretty weird, I think you must be right but I don't know how that error could have gone unnoticed for so long. Anyway, I've edited the answer now. Commented Apr 9, 2015 at 7:11
  • 4
    I found this post saying that there is a severe performance penalty from std::function. Commented Jun 28, 2015 at 21:56
  • 4
    @kevin, you may want to revise your comment, as that post's answers showed a flaw in the benchmark. Commented Jan 3, 2020 at 8:53