Kurt Nørmark
Department of Computer Science, Aalborg University
Abstract Previous lecture Index References Contents | ... |
Iterators |
Iterators seen as generalized pointers Slide Contents Index References |
|
|
|
|
|
Example uses of iterators - basic stuff Slide Contents Index References |
|
Program: A really simple example of iterators. |
|
Program: The same program using a reverse iterator. |
|
Program: Equivalent program with range-for - with iterators abstracted away - C++11. |
|
Different classifications of iterators Slide Contents Index References |
|
|
|
|
Categories of iterators Slide Contents Index References |
|
|
|
|
|
|
Insert iterators Slide Contents Index References |
|
|
|
Program: Output insert-iterators and factory functions that create such iterators. |
|
Program: Same program - simplified in various ways in C++11. |
|
|
Standard Containers |
Documentation of the container library Slide Contents Index References |
|
|
Overview of containers Slide Contents Index References |
|
|
|
|
|
|
|
Common properties of containers Slide Contents Index References |
|
|
|
|
A priority queue example Slide Contents Index References |
|
|
|
|
Program: Illustration of priority_queue<Point, deque<Point> >. |
|
Program: Class point with an overloaded operator<. |
|
Program: The implementation of class Point and in particular operator<. |
|
A map example Slide Contents Index References |
|
|
Program: Illustration of the map standard container. |
|
Program: Alternative version - using range-for for traveral of the map. |
|
Program: Sample program input. |
|
|
Program: Program output - as produced on the input from above. |
|
Container member types Slide Contents Index References |
|
|
|
|
|
Program: Illustration of the use of member types for a list of chars. |
|
Program: Same program - now with use of typename as prefix of 'nested dependent type names'. |
|
|
Member types - ambiguities Slide Contents Index References |
|
Program: Illustration of a couple of ambiguities. |
|
Program: Compiler error messages. |
|
Program: Ambiguities resolved. |
|
Program: An alternative resolution of the ambiguity . |
|
A vector specialization: vector<bool> Slide Contents Index References |
|
|
|
Program: Illustration of the use of vector<bool>. |
|
Program: Another slightly more complicated (almost) equivalent program. |
|
Algorithms |
Documentation of the algorithms library Slide Contents Index References |
|
Overview of Algorithms Slide Contents Index References |
|
|
|
|
Principles used for algorithms Slide Contents Index References |
|
|
|
The for-each algorithm Slide Contents Index References |
|
Program: A possible implementation of the for-each algorithm. |
|
|
Program: Implementation and sample use of for-each on an C-style array. |
|
Program: Implementation and sample use of for-each on a list of integers. |
|
Program: Use of std::for-each instead of our own definition of for-each. |
|
|
Function objects Slide Contents Index References |
|
|
|
|
Program: Class Point with overloadings of the application operator. |
|
Program: Definition of funny Point application operators. |
|
Program: Sample uses of the application operators - Funny and artificial. |
|
|
Program: Class Point with another overloading of the application operator. |
|
Program: Definition of then Point application operator. |
|
Program: Sample uses of the application operators - slightly more realistic. |
|
Using the sort algorithm Slide Contents Index References |
|
|
Program: Two overloads of the sort function template. |
|
Program: Sorting a vector of integers. |
|
Program: Program output. |
|
An example of for-each and function objects Slide Contents Index References |
|
Program: A possible use of for-each to solve this problem. |
|
|
Program: Following the advice: Solve the problem with a more appropriate algorithm. |
|
|
Program: Possible definitions of the type greater and its base class. |
|
Use of function objects in STL Slide Contents Index References |
|
|
|
|
Adapter examples Slide Contents Index References |
|
Program: An illustration of plus<double>. |
|
Program: A possible definition of plus. |
|
Program: Another definition of plus - as a function template. |
|
Program: Yet another alternative where a lambda expression is used. |
|
Program: Illustration of member function adaptions. |
|
Program: The definition of Point - point.h. |
|
Generic Programming and Metaprogramming |
What is generic programming in C++? Slide Contents Index References |
|
|
|
|
What is metaprogramming in C++? Slide Contents Index References |
|
|
|
|
|
What is metaprogramming used for in C++? Slide Contents Index References |
|
|
|
Static assert Slide Contents Index References |
|
Program: Static assert about the size of int. |
|
Program: Compilation of p1.cpp. |
|
Program: Static asserts abstracted in constexpr function. |
|
Program: Compilation of p4.cpp. |
|
|
Program: An example a static_assert in a template user specialization program. |
|
Exercise 6.2. Working with static_assert | In this program on the accompanying slide the static_assert holds. In main, enforce a couple of other template instantiations that will cause the static_assert to fail. |
|
Type functions Slide Contents Index References |
|
|
|
Program: Illustration of of type functions in a number static assertions - all of which hold. |
|
|
Constant expressions in C++11 Slide Contents Index References |
|
|
|
|
|
Examples of constant expressions Slide Contents Index References |
|
Program: Examples of constant expressions - C++11. |
|
Program: The same program - with results statically asserted. |
|
Program: Evaluation of constexpr at run-time - C++11. |
|
Program: Relaxed constexpr in C++14. |
|
Program: Examples of a literal type, struct Point - C++11. |
|
Program: The same program - with results statically asserted. |
|
Program: Examples of class Circle with a constexpr constructor - C++11. |
|
Selection between two types Slide Contents Index References |
|
|
Program: An sample use of conditional. |
|
Program: Same - syntactically embellished. |
|
Program: Use of my_conditional in the example from above. |
|
Program: Possible definition of conditional - here as my_conditional. |
|
Program: Use of my_conditional - in the example from above. |
|
Selection between two functions Slide Contents Index References |
|
|
Program: Selection one of two functions at compile time. |
|
|
Conditional declarations Slide Contents Index References |
|
|
Program: Class Point header file - where move is only enabled for floating point types. |
|
Program: Implementation of Point<C> members. |
|
Program: Use of class Point<double> with move - OK. |
|
Program: Use of class Point |
|
Example of type function: Integer of given byte size Slide Contents Index References |
|
|
|
|
Program: First version of type function. |
|
Program: Second version of type function - embellished syntax of the type function. |
|
Program: The ugly and bulky selection stuff. |
|
Generalizing Select with use of a variadic template Slide Contents Index References |
|
|
Program: Yet another version of type function - generalized to selection among an arbitrary number of types. |
|
Program: General selection stuff - shorter and more elegant - using variadic templates (C++11). |
|
Compile Time iteration Slide Contents Index References |
|
Program: The factorial function defined as a constexpr function (C++11). |
|
Program: The factorial function defined as a function template - using a template int parameter. |
|
Program: The factorial function programmed in struct - with recursion. |
|
More compile time computations - older stuff Slide Contents Index References |
|
Program: The factorial function - from Wikipedia. |
|
Program: The power function on integer type arguments. |
|
Program: The power function on integer type arguments - alternative implementation with an enumeration constant. |
|
|
Program: A more advanced version of the power function - from Stack Overflow. |
|
Program: A variant of the more advanced version of the power function. |
|
Program: Program output - both versions. |
|
|
Collected references Contents Index |
|
Chapter 6: The Standard Library and Metaprogramming
Course home Author home About producing this web Previous lecture (top) Next lecture (top) Previous lecture (bund) Next lecture (bund)
Generated: August 1, 2017, 13:31:59