I'm following the example at the following link:
https://www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/high_precision/use_multiprecision.html
I get an error on the following line:
[&n](cpp_dec_float_50& y)
g++ -I ../boost_1_71_0 fft.cpp -o fft
fft.cpp:52:3: error: expected expression
[&n](cpp_dec_float_50& y)
^
1 error generated.
The full block is:
// Generate the sine values.
std::for_each
(
sin_values.begin (),
sin_values.end (),
[&n](cpp_dec_float_50& y)
{
y = sin( pi<cpp_dec_float_50>() / pow(cpp_dec_float_50 (2), n));
++n;
}
);
What is "[&n](cpp_dec_float_50& y)" actually doing? And why is it erroring?
What is
[&n](cpp_dec_float_50& y)actually doing?
It's the first part of a lambda expression, i.e. an anonymous function.
And why is it erroring?
You need to compile for C++11 (or higher). Use -std=c++11 (or -std=c++14 or -std=c++17) in your compiler command line. eg:
g++ -std=c++11 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With