Exploring the C++ Standard Library

“Exploring the C++ Standard Library” is a two-day training course with programming exercises taught by Christopher Di Bella. It is offered at the Sheraton Bellevue Hotel from 9AM to 5PM on Saturday and Sunday, September 30th and October 1st (immediately after the conference). Lunch is included.

Course Description

Make Simple Tasks Simple! and Back to the Basics! Essentials of Modern C++ Design were two powerfully-delivered keynotes at CppCon 2014. Both Stroustrup and Sutter ask us to write clean, simple code that expresses our intentions. A year later, they asked us to start using the CppCoreGuidelines, and more recently, Bjarne unveiled the future of C++. But what does all of this mean?

How can I take my Super Complex Algorithm™ and make it a Simple Task™? you may wonder. Some engineers prefer to hand-write code that works so they can move on to more interesting problems: sometimes it is indeed faster to write the algorithm that you’re thinking about instead of stopping and thinking about your true intentions for an algorithm. Never mind the QA that needs to happen, or the hidden corner case that you now own because you missed it during testing.

If only there was a library that could reduce the amount of time that you spend programming and testing. Behold, the C++ Standard Library! We’ll explore the Standard library, and explore how to turn genuine code samples from Super Complex Algorithm™ into Simple Task™. The Standard Library is extremely an well-supported library that is very well-tested across the major compilers, and is therefore less likely to have bugs than handwritten data structures and algorithms. You’ll also be able to give your algorithms descriptive names to help reduce those pesky comments that supposedly go out of date. We won’t just be exploring the STL, but the broader library that encompasses even some of the more recent features of C++ (C++17 features subject to compiler availability).

We’ll also explore the Concepts TS and the newly minted Ranges TS, and how it can make our code more expressive, safer, and change horrible template errors from PhD theses, to short and meaningful error messages.

Prerequisites

  • Minimum experience: 3+ months expereince in C++, including familiarity with templates
  • Target audience: Beginners, intermediate, advanced
  • Operating system: Windows, Linux, OS X
  • Tools for Windows users: Bash for Windows (preferred) or MinGW
  • Tools for all:
    • git
    • a GitHub account
    • a web browser
  • Compiler: TBA August
  • Libraries:
    • cmcstl2,
    • range-v3
    • Microsoft’s GSL implementation
    • a recent version of Boost

Course Topics

  1. Basics
    1. vector, string, map
    2. Standard algorithms survey
    3. Performance testing with chrono
    4. GSL contracts
    5. a very light introduction to the Concepts TS and the Ranges TS
  2. I/O, text processing, regex
  3. Invocables
  4. Containers, standard views, GSL spans
  5. Iterators
  6. Utilities
    1. tuple
    2. optional
    3. variant
    4. PRNGs
  7. Writing a container-like structure
  8. Container refinement: smart pointers
  9. Container refinement: exception handling
  10. Dynamic memory allocation
    1. placement new
    2. allocator
    3. manual dynamic memory allocation vs vector

We will look at practical aspects for most topics: this will sometimes include a case study.

Thread support and atomic operations are not included in this class. Please attend Anthony Williams’ class if you would like to learn about C++ concurrency in action.

Course Instructor

Christopher Di Bella is a full time software developer at a financial company in Sydney, a casual tutor for a C++ course at UNSW Australia, and an avid C++ programmer.