Difference between revisions of "Intermediate C++ Game Programming Tutorial 25"
From Chilipedia
(→Video Timestamp Index) |
(→Tutorial 25 - Bonus) |
||
Line 179: | Line 179: | ||
</div> | </div> | ||
=== [https://youtu.be/4EZVTNHmojc Tutorial 25 - Bonus] === | === [https://youtu.be/4EZVTNHmojc Tutorial 25 - Bonus] === | ||
+ | <div class="mw-collapsible mw-collapsed"><br /> | ||
+ | * Pointers to a member function of a class/struct [https://youtu.be/4EZVTNHmojc?t=7s 0:07] | ||
=== [https://youtu.be/Vh2JW5MHJX0 Tutorial 25 - Solution] === | === [https://youtu.be/Vh2JW5MHJX0 Tutorial 25 - Solution] === |
Revision as of 19:21, 16 February 2020
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]