Skip to content

Commit d46b0e6

Browse files
amadiobernhardmgruber
authored andcommitted
Update slide on static_assert
- Available since C++11, only single argument version is C++17 - Make error message in example fit within the slide
1 parent 634a353 commit d46b0e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

talk/basicconcepts/assert.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
\end{frame}
6565

6666
\begin{frame}[fragile]
67-
\frametitlecpp[17]{Static Assert}
67+
\frametitlecpp[11]{Static Assert}
6868
\begin{block}{Checking invariants at compile time}
6969
\begin{itemize}
7070
\item To check invariants at compile time, use \mintinline{cpp}{static_assert}
7171
\item The assertion can be any constant expression (see later)
72-
\item No runtime penalty!
72+
\item The message argument is optional in \cpp 17 and later
7373
\end{itemize}
7474
\end{block}
7575
\begin{exampleblock}{\texttt{static\_assert}}
@@ -86,7 +86,8 @@
8686
\scriptsize
8787
\begin{Verbatim}[commandchars=\\\{\}]
8888
a.cpp: In function 'double f(UserType)':
89-
\textcolor{blue}{a.cpp:3:9:} \textcolor{red}{error:} \textcolor{blue}{static assertion failed: This function expects floating-point types.}
89+
\textcolor{blue}{a.cpp:3:9:} \textcolor{red}{error:} \textcolor{blue}{static assertion failed: This function}
90+
\textcolor{blue}{expects floating-point types.}
9091
2 | static_assert(
9192
| \textcolor{red}{std::is_floating_point_v<UserType>},
9293
| \textcolor{red}{~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

0 commit comments

Comments
 (0)