void fractal(window<int> &scr, window<double> &fract, int iter_max, std::vector<int> &colors, const std::function<std::complex<double(std::complex<double>, std::complex<double>)> &func, const char *fname, bool smooth_color);
escape's function signature is much simpler:
int escape(std::complex<double> c, int iter_max, const std::function<std::complex<double>(std::complex<double>,
std::complex<double>)> &func)
At least we get to use "auto" when we define func, though: auto func = [] (std::complex <double> z, std::complex<double> c) -> std::complex<double> {return z * z * z + c; };template< typename Func > int escape(std::complex<double> c, int iter_max, Func& func)
...then I realized that it was only a baroque type declaration and that scrolling down the page reveals tons of additional code blocks... and those aren't actually all the code.
(C++ is still a great language for many problem domains... Code brevity/elegance is not its strength however.)
auto func = [] (std::complex <double> z, std::complex<double> c) -> std::complex<double> {return z * z + c; };
Why isn't there some nicer and more readable syntax for some of that basic stuff?!
auto func = [] (std::complex<double> z, std::complex<double> c) { return z * z + c; };
You could also typedef the number type somewhere: typedef std::complex<double> Complex;
// ...
auto func = [] (Complex z, Complex c) { return z * z + c; };
I think that last one looks ok.Edit: I found the following links concerning this topic:
http://root.cern.ch/drupal/content/c14 http://isocpp.org/blog/2012/12/an-implementation-of-generic-...
And the paper: http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3418.pd...
auto func = [](cdouble z, cdouble c) -> cdouble { return z * z + c; }