| |
|
C++ Templates and the STL in Depth
This two-day course takes an in-depth look at one of the most ingenious libraries ever written - still known, albeit unofficially now, as the STL or standard template library. This library is usually turned to when collection objects are needed; but it has more, much more, than that. It is also one of the best combinations of efficiency and industrial strength you are likely ever to see in a library.
Background
Although mentioned and introduced in other courses, such as the introductory and advanced C++ courses, using the STL properly required a significant amount of study.
C++ can be used in many ways. Possibly the most common is object-oriented. Probably the next most common is generic, or template-based. Generic programming turns out to be much more difficult, but more efficient, than object-oriented programming. Frequently only with libraries and toolkits does one have the pressing need and the necessary time and expertise resources to use generic C++ rather than, say, object-oriented C++.
During the early 1990s, Alexander Stepanov, whose backgrounds were mathematics and real-time operating systems (and who once said in an interview that he thought object-orientation to be something of a hoax), and David Musser coalesced their 1980s research on generic programming techniques into the beginnings of the STL at HP Labs in Palo Alto. Meng Lee then turned the work into a practical, packaged entity. And, thanks in large part to Bjarne Stroustrup efforts, the STL was accepted into the 1998 C++ standard. Stepanov moved to Silicon Graphics in 1995, where research on the STL continued and where it was thoroughly documented by Matt Austern.
Whether your interest is in learning generic programming techniques from one of the best examples around, or whether your object-oriented (or otherwise) C++ code requires collections and their associated functionality, the STL will amply repay careful study.
Aims
- To understand the principles of generic programming and the C++ template mechanisms;
- To understand the workings of tempate classes, template member functions and template functions
- To practise writing template functions and classes
- To understand the mechanisms and differentiating characteristics of static polymorphism versus dynamic polymorphism, and to understand why the STL has documented "concepts" rather than abstract base classes;
- To acquaint participants with the contents of the STL: containers, iterators, algorithms, adaptors, functors, utilities, allocators, typedefs and base classes;
- To practise using containers, iterators, algorithms, adaptors, functors, utilities, typedefs and base classes;
- To acquaint participants with the philosophy underlying the design of the STL;
- To understand, and get the best from, the documentation of the STL, especially the documentation of the STL's "concepts", such as Equality Comparable or Pair Associative Container, and its complexity specifications;
- To understand the tradeoffs among the myriad ways of accomplishing a given programming goal with the STL.
Audience
This course is for C++ users who perhaps want to begin acquiring generic programming skills, and who need to use the provisions of the STL in a knowledgeable and insightful way.
Pre-requisites
Course participants will already have a thorough knowledge of the C++ language in terms of its syntax and of the way in which it works—the nature of pointers and pointer arithmetic for example. Participants would not need to know object-orientation or object-oriented design.
Duration and Construction
The course lasts two days, typically from 0900 to 1630 and is delivered via lecture, practice and discussion. Start, end and break times can be tailored to suit individual sites.
Delivery
Courses are normally delivered at the customer site.
Platform
The course is normally delivered using the PC/Windows platform, using the Visual C++ compiler (version 6 or version .NET). The course content, however, is platform-neutral. The course can also be delivered via other platforms, Linux with gnu C++ for example, by prior arrangement.
Content
Generic programming
- The theories, benefits and difficulties of generic programming
- Generic programming (or static polymorphism) briefly contrasted with dynamic polymorphism (object-orientation)
C++ Templates
- Template functions
- C++'s function overload resolution mechanism
- Template function specialization
- Template classes
- Template member functions and partial specialization
The Standard Library and the STL
- The contents of the standard library
- The std namespace
- The place of the "STL "
The Makeup of the STL
- Brief introduction to containers, algorithms, iterators, adaptors and utilities
"Concepts"
- The absence of C++ typing (no abstract classes)
- The concept of "concepts"
- Introduction to some of the important "concepts "
Containers
- The need for containers
- The sequences
- The associative containers
- The container services
- The stack, queue and priority_queue container adaptors
- Non-standard containers such as a rope (a heavy-duty string)
Iterators
- The iterator concepts
- Using iterators
- Why we use iterators
- Stream iterators
- Iterator adaptors
- Tags and traits
Arrays and Pointers
- How the built-in (C) arrays and pointers implement container and iterator concepts
Choosing Wisely I
- Inserting and erasing via iterators
- Inserting and erasing via container member functions
The Algorithms
- Non-mutating
- Mutating
- Sorting, searching, set and heap operations
Choosing Wisely II
- The right container
- The right algorithm
- Algorithms versus member functions
Function objects
- The power of functors or function objects
- Creating function objects
- Creating predicate function objects
- The predefined functors in the library
- Adaptors and binders
- Adaptable functors and the base classes
Finishing up
- Remaining utilities and adaptors
- Allocators
- C++0x and the future
Contacting
Please contact John Deacon by telephone on +44 20 7498 3773; by fax on +44 20 7498 3747; by emailing jdeacon@jdl.co.uk; or by visiting http://www.jdl.co.uk
[ Home page | Courses List ]
Last modified:
Thursday, 08-Feb-2007.
Copyright © 2007 John Deacon. All rights reserved.
|