Intermediate C++ Game Programming Tutorial 25
From Chilipedia
Function pointers allow you to store and change what function is to be called dynamically at runtime. Combine that with containers to have collections of actions/behaviors that can be selected from, and then jam in the power std::function
to allow you to wrap up pretty much any kind of callable thing and bring them together in one container. Groovy.
Contents
[hide]Topics Covered
- Function pointers
- Functionoids
-
std::function
Bonus Video
- Pointers to member functions
- std::bind
- std::mem_fn
- std::reference_wrapper (a little)
- Pointer to static member function (it's the same as for normal funcy bois)
- You can use normal func pointers for lambdas if they do not capture anything
Video Timestamp Index
Tutorial 25
[Expand]
- How to switch on a string? (execute some code based on the string passed to the switch): using Functionoids 0:15
- Introducing Function Pointers 5:13
- Using Function Pointers with a map 7:27
- Alternative route: use
std::function<>
in order to map to lambda functions 9:33
- Example: making a single string switch class 13:01
- Homework assignment: time to face the music 20:06
Tutorial 25 - Bonus
[Expand]