Skip to content

Commit 47defb0

Browse files
Sebastien Poncesponce
Sebastien Ponce
authored andcommitted
Tiny fixes after rehearsal of advanced course
1 parent b7cf681 commit 47defb0

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

talk/basicconcepts/classenum.tex

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
VehicleType t = CAR;
113113
\end{cppcode*}
114114
\columnbreak
115-
\begin{cppcode*}{gobble=2}
115+
\begin{cppcode*}{gobble=2,firstnumber=8}
116116
enum VehicleType
117117
: int { // C++11
118118
BIKE = 3,
@@ -139,7 +139,7 @@
139139
\item strong typing, no automatic conversion to int
140140
\end{itemize}
141141
\small
142-
\begin{cppcode*}{}
142+
\begin{cppcode*}{firstnumber=3}
143143
enum VType { Bus, Car }; enum Color { Red, Blue };
144144
VType t = Bus;
145145
if (t == Red) { /* We do enter */ }
@@ -210,7 +210,7 @@
210210
\end{cppcode*}
211211
\end{alertblock}
212212
\begin{exampleblock}{\cpp11}
213-
\begin{cppcode*}{gobble=2}
213+
\begin{cppcode*}{gobble=2,firstnumber=4}
214214
using myint = uint64_t;
215215
myint toto = 17;
216216
using pos = int[3];

talk/basicconcepts/control.tex

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
\pause
160160
\begin{alertblock}{\cpp98}
161161
Don't confuse with a variable declaration as condition:
162-
\begin{cppcode*}{}
162+
\begin{cppcode*}{firstnumber=7}
163163
if (Value* val = GetValuePtr())
164164
f(*val);
165165
\end{cppcode*}
@@ -183,7 +183,7 @@
183183
\end{block}
184184
\pause
185185
\begin{exampleblock}{Practical example}
186-
\begin{cppcode*}{}
186+
\begin{cppcode*}{firstnumber=4}
187187
for(int i = 0, j = 0 ; i < 10 ; i++, j = i*i) {
188188
std::cout << i << "^2 is " << j << '\n';
189189
}
@@ -213,7 +213,7 @@
213213
\end{cppcode*}
214214
\end{block}
215215
\begin{exampleblock}{Example code}
216-
\begin{cppcode*}{}
216+
\begin{cppcode*}{firstnumber=4}
217217
int v[4] = {1,2,3,4};
218218
int sum = 0;
219219
for (int a : v) { sum += a; }
@@ -236,7 +236,7 @@
236236
\end{cppcode*}
237237
\end{alertblock}
238238
\begin{exampleblock}{\cpp20}
239-
\begin{cppcode*}{}
239+
\begin{cppcode*}{firstnumber=6}
240240
std::array data = {"hello", ",", "world"};
241241
for (std::size_t i = 0; auto& d : data) {
242242
std::cout << i++ << ' ' << d << '\n';

talk/basicconcepts/scopesnamespaces.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
\end{itemize}
179179
\end{block}
180180
\begin{alertblock}{Supersedes static}
181-
\begin{cppcode*}{gobble=2}
181+
\begin{cppcode*}{gobble=2,firstnumber=4}
182182
static int localVar; // equivalent C code
183183
\end{cppcode*}
184184
\end{alertblock}

talk/morelanguage/exceptions.tex

+6-3
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@
336336
\end{itemize}
337337
\end{block}
338338
\begin{block}{}
339-
\begin{cppcode*}{gobble=2, linenos=false}
339+
\begin{cppcode*}{gobble=2}
340340
constexpr bool callCannotThrow = noexcept(f());
341341
if constexpr (callCannotThrow) { ... }
342342
\end{cppcode*}
343343
\end{block}
344344
\begin{block}{}
345-
\begin{cppcode*}{gobble=2, linenos=false}
345+
\begin{cppcode*}{gobble=2,firstnumber=3}
346346
template <typename Function>
347347
void g(Function f) noexcept(noexcept(f())) {
348348
...
@@ -394,7 +394,10 @@
394394
\item Return a \mintinline{cpp}{std::error_code} (\cpp11)
395395
\item If failing to produce a value is not a hard error, consider returning \mintinline{cpp}{std::optional<T>} (\cpp17)
396396
\item Return \mintinline{cpp}{std::expected<T, E>} (\cpp23), where \mintinline{cpp}{T} is the return type on success and \mintinline{cpp}{E} is the type on failure
397-
\item Terminate the program, e.g.\ by calling \mintinline{cpp}{std::terminate()} or \mintinline{cpp}{std::abort()}
397+
\item Terminate the program
398+
\begin{itemize}
399+
\item e.g.\ by calling \mintinline{cpp}{std::terminate()} or \mintinline{cpp}{std::abort()}
400+
\end{itemize}
398401
\item Contracts: Specify function pre- and postconditions. Planned for \cpp20, but removed. Will come back in the future
399402
\end{itemize}
400403
\end{block}

talk/objectorientation/typecasting.tex

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@
2525
\small
2626
\begin{exampleblock}{}
2727
\begin{cppcode*}{gobble=2}
28-
struct A{ virtual ~A()=default } a;
28+
struct A{ virtual ~A()=default; } a;
2929
struct B : A {} b;
3030

3131
A& c = static_cast<A&>(b); // OK. b is also an A
3232
B& d = static_cast<B&>(a); // UB: a is not a B
3333
B& e = static_cast<B&>(c); // OK. c is a B
3434

3535
B& f = dynamic_cast<B&>(c); // OK, c is a B
36-
B& g = dynamic_cast<B&>(a); // Exception: not a B
37-
38-
B* d = dynamic_cast<B*>(&a); // nullptr. a not a B.
39-
if (d != nullptr) {
40-
// Will not reach this
36+
B& g = dynamic_cast<B&>(a); // throws std::bad_cast
37+
B& foo(A& h) {
38+
return dynamic_cast<B&>(h);
4139
}
40+
B& i = foo(c); // OK, c is a B
4241

43-
if (auto bPtr = dynamic_cast<B*>(&c)) {
44-
// OK, we will get here
42+
B* j = dynamic_cast<B*>(&a); // nullptr. a not a B.
43+
if (j != nullptr) {
44+
// Will not reach this
4545
}
4646
\end{cppcode*}
4747
\end{exampleblock}

0 commit comments

Comments
 (0)