File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 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 }}
8686 \scriptsize
8787 \begin {Verbatim }[commandchars=\\\{\}]
8888a.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}{~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
You can’t perform that action at this time.
0 commit comments