DM852 - Introduction to Generic Programming, 2019

Course description


(Official schedule)

Week Day Notes and Material (Additional) Reading
6 Monday Course introduction (slides), C++ introduction (slides, code)
Tuesday C++ introduction (cont.), Values, types, objects, and variables (slides, code) ([TMPL] Appendix A, The ODR)
Thursday (no class) Exercise suggestions
Friday Values, types, objects, and variables (cont.), Operators, overloading, and friends (slides, code)
7   (no classes) Exercises
8 Monday (no class)
Tuesday Regular Types (slides) Inheritance and polymorphism (slides, code), Exceptions (slides, code), [DeSt], [DA]
Thursday Exceptions (cont.), Conversions, Value Categories, and Moving (slides, code) [TMPL] Appendix B, [BS:10]
Friday (cancelled)
9 Tuesday Conversions, Value Categories, and Moving (cont.), Template Basics (slides, code) [TMPL] Ch. 1, 2, 3, (5), 10, ([DV])
Thursday Template Basics (cont.), Iterators, Ranges, and Algorithms (slides, code) ([TMPL] Ch. 8.1-8.3, 9, Appendix C)
Friday Iterators, Ranges, and Algorithms (cont.), Containers and Function Objects (slides, code)
10 Monday Template Argument Deduction (slides, code), std::move, std::forward [TMPL] Ch. 15 (except 15.4, 15.5), ([SM], [TMPL] Ch. 7 and [RP])
Tuesday Elaboration on copying, moving, value categories, and perfect forwarding (code) ([TMPL] Ch. 6.1)
Thursday (no class) Exercise with code.
Friday Associated Types and Type Traits (slides, code), Tag Dispatching (slides, code) ([TMPL] Ch. 19.1-3, 19.8, 19.10, 19.11)
11 Tuesday Tag Dispatching (cont.)
Thursday Smart Pointers, Empty Base Optimization, Argument-Dependent Lookup (slides, code) [TMPL] Ch. 21.1, ([HS], [AK])
Friday Smart Pointers, Empty Base Optimization, Argument-Dependent Lookup (cont.)  
12 Tuesday Overview of Polymorphism and Static Polymorphism with CRTP (slides, code), Graph library discussion [CW], [TMPL] Ch. 18, 21.2
Thursday Overview of Polymorphism and Static Polymorphism with CRTP (cont.), Graph library discussion (cont.)
Friday Constrained Templates and SFINAE (slides, code) [TMPL] Ch. 8.4, 15.7, 19.4.1, 19.4.2
13 Tuesday Constrained Templates and SFINAE (cont.), Concepts as a Language Construct (slides, code) ([WB2])
Thursday (no class)
Friday Visitors for Graph Algoritms (slides, code), Introduction to Exam Project ([BGL])
14 Sunday Mandatory assignment deadline
19 Sunday Exam project deadline

Mandatory Assignment

This is a prerequisite (“forudsætningsprøve”) for the exam.

Description and example code.


Deadline: Sunday 7 April at 23:59 CEST.

Exam Project

Description and code archive (12 April: desc.pdf and topological_sort.hpp updated due to a few typos, 29 April: desc.pdf updated so it doesn’t refer to a non-existing header file).


Deadline: Sunday 12 May at 23:59 CEST.


Additional Resources

Installing GCC \(\geq\) 6

Note, if you use Ubuntu 18.04, the default GCC package is already new enough. That is, simply do:

sudo apt-get install g++

If you want to try an even newer version, see below.


sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-8

From Source

(See also

  1. Download and unpack the sources, e.g.:

    tar xzf gcc-8.2.0.tar.gz
  2. Download prerequisites:

    cd gcc-8.2.0
  3. Configure, build, and install (see for information on the options), e.g.,:

    mkdir build
    cd build
    ../configure --prefix=<where you want to install it> --program-suffix=-8 --disable-multilib
    make -j <number of threads to compile with>
    make install

Installing the Boost Libraries


Note, this may be a relatively old version.

sudo apt-get install libboost-all-dev