DM852 - Introduction to Generic Programming, 2019¶
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),
|
[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 |
|||
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 |
[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.
Attention
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).
Attention
Deadline: Sunday 12 May at 23:59 CEST.
Literature¶
- [TMPL] C++ Templates, The Complete Guide, 2nd EditionAuthors: David Vandevoorde, Nicolai Josuttis, Douglas GregorYear: 2017ISBN: 9780321714121Source code for examples: tar archive
- [DeSt] Fundamentals of Generic Programming. James C. Dehnert and Alexander Stepanov. In Generic Programming, LNCS 1766, Spring, 2000. [DOI | TR](see also Revisiting Regular Types, Titus Winters)
[DA] Exception-Safety in Generic Components, David Abrahams, 2001
[BS:10] “New” Value Terminology, Bjarne Stroustrup, 2010
[CW] Section 1.1 to 1.4 of On Understanding Types, Data Abstraction, and Polymorphism (PDF), Luca Cardelli and Peter Wegner, ACM Comput. Surv., 1985.
Additional Resources¶
Language reference: C++ reference
Online Compiler Explorer
[DV] Down with
typename
!, Daveed Vandevoorde, 2017. A newer revision is accepted for C++20 (and implemented in GCC 9). A proposal to avoid having to typetypename
in so many places. See also [TMPL] Ch. 17.1.constexpr
ALL the things!, Ben Deane and Jason Turner, C++Now 2017 (slides). A talk on parsing JSON at compile-time.The World Map of C++ STL Algorithms, Jonathan Boccara, 2018. A blog post and video giving an overview of the standard algorithms.
[SM] Type Deduction and Why You Care, Scott Meyers, CppCon 2014.
[RP] How to Argue(ment), Richard Powell, CppCon 2018 (slides). A discussion on how to decide on which argument type to use.
[WB] What C++ Programmers Need to Know about Header
<random>
, Walter E. Brown, 2016[HS] Leak-Freedom in C++… By Default, Herb Sutter, CppCon 2016.
[AK] A Personal Note About Argument-Dependent Lookup, Andrew Koenig, 2012.
[BGL] The Boost Graph library.
[BI] The Boost Iterator library.
[WB2] Proposing Standard Library Support for the C++ Detection Idiom, Walter E. Brown, 2015.
Utility programs:
c++-filt
: demangle symbolsnm
: list symbols from compiled files (e.g.,.o
,.a
,.so
, and executables). Usenm -C
to demangle the symbols, or equivalentlynm myFile | c++filt
.valgrind
: detect errors related to memory
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.
Ubuntu¶
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-8
From Source¶
(See also https://gcc.gnu.org/wiki/InstallingGCC)
Download and unpack the sources, e.g.:
wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz tar xzf gcc-8.2.0.tar.gz
Download prerequisites:
cd gcc-8.2.0 ./contrib/download_prerequisites
Configure, build, and install (see https://gcc.gnu.org/install/configure.html 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