The Importance of std::function -- Malte Skarupke

See also "Generalizing Observer", written ten years ago when std::function was first adopted.

The Importance of std::function

by Malte Skarupke

... Classically an update loop would be implemented something like this: ...

And this is a good solution at first. But you’ve got that inheritance in there, and that doesn’t scale. You will probably want to add a render loop and maybe a separate update loop for the editor. Once you’ve got that many base classes it makes sense to combine them into one. And now you’ve just started on the way of having a big base class that gets used everywhere. Soon enough adding something different to the update loop involves a whole lot of unnecessary work.

Here is an alternate update loop using std::function: ...

 

Add a Comment

Comments are closed.

Comments (1)

0 0

Joel Lamotte said on Mar 5, 2013 01:17 PM:

I think that the examples given in this article might be misleading beginners.