Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
STL C++ Iterators - Writing an iterator from scratch | Modern Cpp Series Ep. 138
Play lesson

The C++ Programming Language - STL C++ Iterators - Writing an iterator from scratch | Modern Cpp Series Ep. 138

4.0 (5)
38 learners

What you'll learn

This course includes

  • 68.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Full Transcript

►Full C++ Series Playlist: https://www.youtube.com/playlist?list=PLvv0ScY6vfd8j-tlhYVPYgiIyXduu6m-L ►Find full courses on: https://courses.mshah.io/ ►Join as Member to Support the channel: https://www.youtube.com/channel/UCA64pZbN5Mz5NxC3SO4qpDg/join ►Lesson Description: In this lesson I show you how to write an iterator from scratch that is compatible with range-based for-loops. We'll set the stage for how to also make this iterator compatible with several std::algorithm STL algorithms as well! 00:00 Introduction 00:58 Iterators review and use 03:50 Example of STL vector and usage with iterators 05:40 Cpp insights view of ranged-based for loops and iterators 08:00 Swapping STL data structures 08:45 Figuring out which member functions we need for iterators 09:41 Example data structure explanation 11:40 Adding 'begin' and 'end' stubs and 'iterator' struct 14:00 Adding 'struct iterator' 14:40 Design Decision on our iterators bookkeeping strategy 15:25 iterator Constructor 16:12 Idea that we can have multiple iterators to same container 17:20 Cleaning up our iterator, inspired by STL design 18:30 Placeholders for distance (ptrdiff_t) 19:40 Placeholder for iterator category 21:40 Filling out 'begin' and 'end' 23:28 'end' is beyond the data structure 24:58 Implementing pre increment and post increment 29:07 Dereference operator 31:00 Adding arrow operator 32:53 Implementing "operator==" and "operator!=" 35:20 Fixing bug with pre increment 36:00 WORKING iterator -- very cool! 37:40 Review of our implementation 40:30 Wrap up and thank you to our members and subscribers ►YouTube Channel: https://www.youtube.com/c/MikeShah ►Please like and subscribe to help the channel! ►Join our free community: https://courses.mshah.io/communities/Q29tbXVuaXR5LTI3MzAz

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere