Skip to content

Commit

Permalink
Tiny fixes found while preparing next session of the advanced course
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Ponce committed Oct 11, 2023
1 parent 63ad561 commit 8d2bcdf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion talk/C++Course.tex
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
\input{objectorientation/adl}
\end{advanced}

\section[More]{Core modern \cpp}
\section[Core]{Core modern \cpp}
\input{morelanguage/constness}
\begin{advanced}
\input{morelanguage/constexpr}
Expand Down
6 changes: 3 additions & 3 deletions talk/basicconcepts/assert.tex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
\begin{cppcode*}{}
double f(UserType a) {
static_assert(
std::is_floating_point<UserType>::value,
std::is_floating_point_v<UserType>,
"This function expects floating-point types.");
return std::sqrt(a);
}
Expand All @@ -89,7 +89,7 @@
\textcolor{blue}{a.cpp:3:9:} \textcolor{red}{error:} \textcolor{blue}{static assertion failed: This function}
\textcolor{blue}{expects floating-point types.}
2 | static_assert(
| \textcolor{red}{std::is_floating_point<UserType>::value},
| \textcolor{red}{~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
| \textcolor{red}{std::is_floating_point_v<UserType>},
| \textcolor{red}{~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
\end{Verbatim}
\end{frame}
6 changes: 3 additions & 3 deletions talk/basicconcepts/coresyntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@
#include <stdfloat> // may define these:

std::float16_t = 3.14f16; // 16 (1+5+10) bit float
std::float32_t = 3.14f32; // like float
std::float32_t = 3.14f32; // like float (1+8+23)
// but different type
std::float64_t = 3.14f64; // like double
std::float64_t = 3.14f64; // like double (1+11+52)
// but different type
std::float128_t = 3.14f128; // 128 (1+15+112) bit float
std::bfloat_t = 3.14bf16; // 16 (1+8+7) bit float
std::bfloat16_t = 3.14bf16; // 16 (1+8+7) bit float

// also F16, F32, F64, F128 or BF16 suffix possible
\end{cppcode*}
Expand Down
2 changes: 1 addition & 1 deletion talk/morelanguage/copyelision.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\begin{frame}[fragile]
\frametitlecpp[17]{Copy elision}
\begin{block}{Copy elision}
\begin{block}{Where does it take place ?}
\small
\begin{cppcode*}{}
struct Foo { ... };
Expand Down
2 changes: 1 addition & 1 deletion talk/morelanguage/morestl.tex
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
\begin{cppcode*}{}
std::optional<Phone> parse_phone(std::string_view in) {
if (is_valid_phone(in))
return in; // equiv. to optional<Phone>{in};
return in; // equiv. to optional<Phone>{in};
return {}; // or: return std::nullopt; (empty opt.)
}
if (v) { // or: v.is_valid()
Expand Down
8 changes: 3 additions & 5 deletions talk/objectorientation/typecasting.tex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
\begin{frame}[fragile]
\frametitlecpp[98]{Type casting example}
\small
\begin{exampleblock}{}
\begin{exampleblockGB}{Practically}{https://godbolt.org/z/16faqc64s}{\texttt{casting}}
\begin{cppcode*}{gobble=2}
struct A{ virtual ~A()=default; } a;
struct B : A {} b;
Expand All @@ -34,17 +34,15 @@

B& f = dynamic_cast<B&>(c); // OK, c is a B
B& g = dynamic_cast<B&>(a); // throws std::bad_cast
B& foo(A& h) {
return dynamic_cast<B&>(h);
}
B& foo(A& h) { return dynamic_cast<B&>(h); }
B& i = foo(c); // OK, c is a B

B* j = dynamic_cast<B*>(&a); // nullptr. a not a B.
if (j != nullptr) {
// Will not reach this
}
\end{cppcode*}
\end{exampleblock}
\end{exampleblockGB}
\end{frame}

\begin{frame}[fragile]
Expand Down

0 comments on commit 8d2bcdf

Please sign in to comment.