Modern and Lucid C++ Advanced for Professional Programmers ... · Modul: C++ Advanced (M_CPlA) 4...
Transcript of Modern and Lucid C++ Advanced for Professional Programmers ... · Modul: C++ Advanced (M_CPlA) 4...
Thomas Corbat / Prof. Peter Sommerlad
Rapperswil, 23.2.2018
HS2018
Department I - C Plus Plus
Modern and Lucid C++ Advanced
for Professional Programmers
Part 0 - Introduction
Modul: C++ Advanced (M_CPlA)
4 Credits (2h Vorlesung / 2h Übungen pro Woche)
Testate
3 Abgaben (Zeitpunkt wird bei Bedarf noch angepasst)
Keine Note
Zulassungsbedingung für die Prüfung
Prüfung
120 Minuten
Open Book (Ausnahme alte Prüfungen oder Abschriften davon)
2
Administratives
Wiki: https://wiki.ifs.hsr.ch/CppAdvanced
Wichtig: https!
Austausch von nicht öffentlichen Inhalten über Skripte-Server:
https://skripte.hsr.ch/Informatik/Fachbereich/C++_Advanced/CplA/
\\hsr.ch\root\alg\skripte\Informatik\Fachbereich\C++_Advanced\CplA
Arbeitsumgebung (Vorläufig)
Aktueller Compiler (GCC 7.2.0+): Windows MinGW von https://sourceforge.net/projects/mingw-w64/
VM vom C++ Modul ist verfügbar – nicht aktualisiert
Cevelop (www.cevelop.com)
An Karfreitag kein Unterricht: 30.03.2018
3
Why C++ Advanced?
What is your motivation?
What are your expectations?
4
Topics
Short refresh of C++ topics
New Features in C++17
Move semantics and type deduction
Low level memory management
Compile-time C++
Multi-Threading / Memory Model
Advanced Libraries/Development
Handling Legacy C++
Maybe more
5
Exercises
Typical tasks known from C++
One specific exercise that will be part of several exercises
Bounded Buffer
Start with a simple std::array-based version that will be extended every week
Parts of it will be Testat
6
Cevelop 1.9.1 with Constificator and Ctylechecker
Get Cevelop
at https://www.cevelop.com/download
Install the additional plug-ins Constificator and Ctylechecker
Update site (already configured in Cevelop): https://www.cevelop.com/update/1.9.0
7
Const Placement in Cevelop
Unfortunately, there are still some bugs which prevent const placement to be considered for code
generation
ctrl + shift + a might do the trick
8
Why Place const Right of the Type? (1/2)
const int seems to be more intuitive since it is how you would say the type of ci and ic...
That's is probably the reason why it usually stands on the left
Let's have a look at pointers
We read pointers from the declarator (i.e. right-to-left)
9
int i;const int ci;int const ic;
ci and ic have type
"const int"
int * ip;const int * cip;int const * icp;int * const ipc;const int * const cipc;int const * const icpc;
cicp and icpc have type "const pointer to const int"
Why Place const Right of the Type? (2/2)
Do ca and ac have the same type?
Yes, what is the type?
int * const
It is not only for reading consistency but also for semantic consistency!
10
using alias = int *;
const alias ca;alias const ac;
const applies to its left neighbor; only if there is no left neighbor it applies to its right neighbor
int const * const
const int * cip;int * const ipc;
?
Confusing Mix of mutable and const
The mutable specifier refers to the declared name
What does the following mean?
const makes the pointee int immutable
mutable makes the pointer mutable
When does this make sense? Shouldn't the non-const mutable_const_int_pointer always be
mutable?
11
mutable const int * mutable_const_int_pointer;
Features of Cevelop (Constificator)
Constificator
If activated
Makes suggestions about missing const qualifiers
12
What does Ctylechecker do?
It annoys you in the first place!
When you have multiple ASSERTs in your test cases
When you use std::cin/std::cout outside of the main function
When there are issues with your include guard
13
Hey Apple!
What does Ctylechecker do?
and reports...
... global non-const variables
... missing includes of Standard Library headers and provides a resolution!
... unused includes of Standard Library headers
14
15(New) Features of Cevelop (Templator/Includator)
Template Instance Visualization
New version coming soon
Include Organization
15
16Cevelop 1.9.0 New Project Wizard
Eclipse CDT 9.4 features a new wizard page
for creating new projects
With "C++ Managed Build" you can get to the
familiar wizard
16
17Configure Cevelop for C++17 (Cevelop <= 1.9.0) 17
Resilience Required
You might encounter several bugs in Cevelop and its plug-ins (more than in CPl)
We are using modern and sophisticated features of C++17, which are not completely supported yet
When in doubt ask your compiler
When in more doubt ask several compilers
http://melpon.org/wandbox
https://gcc.godbolt.org/
18