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 64
64
\end {frame }
65
65
66
66
\begin {frame }[fragile]
67
- \frametitlecpp [17 ]{Static Assert}
67
+ \frametitlecpp [11 ]{Static Assert}
68
68
\begin {block }{Checking invariants at compile time}
69
69
\begin {itemize }
70
70
\item To check invariants at compile time, use \mintinline {cpp}{static_assert}
71
71
\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
73
73
\end {itemize }
74
74
\end {block }
75
75
\begin {exampleblock }{\texttt {static\_ assert }}
86
86
\scriptsize
87
87
\begin {Verbatim }[commandchars=\\\{\}]
88
88
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.}
90
91
2 | static_assert(
91
92
| \textcolor{red}{std::is_floating_point_v<UserType>},
92
93
| \textcolor{red}{~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
You can’t perform that action at this time.
0 commit comments