Apply a function with optional input containers.
- Parameters
-
func | The function |
args | The arguments in the form of containers of compatible sizes |
If there are n arguments, func
takes n+1 parameters, where the first argument is the element of this container. For example, here is how to imlement in-place element-wise square root and multiplication:
Container a = ...;
Container res = ...;
res.apply([](
auto v) {
return std::sqrt(v); });
res.apply([](auto v, auto w) { return v * w; }, a);