Intermediate C++ Game Programming Tutorial 15

From Chilipedia
Revision as of 23:12, 13 October 2017 by Chili (Talk | contribs) (Created page with "In this tutorial we learn how to make our own goddamn templates. So much power. Drunk with it we are. We also learn about the concept of a "functor" (dumb name, clever idea),...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In this tutorial we learn how to make our own goddamn templates. So much power. Drunk with it we are. We also learn about the concept of a "functor" (dumb name, clever idea), which is pretty sweet and an integral part of the standard library.

Topics Covered

  • Class template
  • Function template
  • Functors
  • typedef
  • Template parameter deduction

Video Timestamp Index

Tutorial 14

Source Code

Sprite Repo Linked list stack repo

Notes

11:45 The reason why we do not increment the iterator i in the for loop, but instead increment it conditionally in the body of the loop is, if we erase an element, the returned iterator will point to the next element after the erased one, and if we were incrementing every iteration of the loop, it would skip all elements that immediately follow an erased element. Instead, we only increment if we did not erase an element, and this ensures that all elements are tested.

Homework

Modify stack to work with range based for loops.

Links

Iterator Type Reference

Homework

No homework.

See also