O'Reilly logo

Extended STL, Volume 1: Collections and Iterators by Matthew Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Adapting the opendir/readdir API

 

Don’t write 200 lines of code when 10 will do.

 
 --Hal Fulton
 

STL is the meat and grist of your dissertation, stick with it and use it like a heart patient wants to use butter.

 
 --George Frazier

Introduction

In this chapter we’re going to look at the simple UNIX opendir/readdir API and see how, despite having far simpler semantics than the glob API (Chapter 17), the business of writing a serviceable STL extension for it is more involved and results in a collection with more restricted semantics.

The extension described here will be the first involving iterators of class type, something it’s very important to get right. Consequently, I’ll first show you the wrong way to write such classes, and then I’ll ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required