File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed
Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 11{
22 " cpp_file" : " snippet18.cpp" ,
3- " compiler" : " g92" ,
3+ " compiler" : " clang900" ,
4+ " flags" : " -std=c++2a" ,
45 " execute" : true
56}
Original file line number Diff line number Diff line change 11#include < cmath>
2+ #include < iostream>
23
34int main () {
4- auto y = [](auto x) {
5- using T = decltype (x);
5+ auto y = []<typename T>(T x) {
66 T mean = 1 .;
77 T width = 3 .;
88 auto norm = 1 . / std::sqrt (2 . * M_PI);
99 auto arg = (x - mean) / width;
1010 return norm * std::exp (-.5 * arg * arg);
1111 }(.5 );
12-
13- return y;
12+
13+ std::cout << y;
1414}
Original file line number Diff line number Diff line change 1- \ begin{lstlisting} [title=\href{https://godbolt.org/z/3-FVEE }{\texttt{godbolt.org/z/3-FVEE }}]
1+ \ begin{lstlisting} [title=\href{https://godbolt.org/z/NC6DKj }{\texttt{godbolt.org/z/NC6DKj }}]
22#include <cmath>
3+ #include <iostream>
34
45int main() {
5- auto y = [](auto x) {
6- using T = decltype(x);
6+ auto y = []<typename T>(T x) {
77 T mean = 1.;
88 T width = 3.;
99 auto norm = 1. / std::sqrt(2. * M_PI);
1010 auto arg = (x - mean) / width;
1111 return norm * std::exp(-.5 * arg * arg);
1212 }(.5);
13-
14- return y;
13+
14+ std::cout << y;
1515}
1616\end {lstlisting }
You can’t perform that action at this time.
0 commit comments