C+++ Promoting Datatypes with Forward, Apply

So I’m staring at this (stan/math/prim/fun/exp.hpp), good to just ask. I guess in this block of code we’re “forwarding” the datatype of x to v, and then applying (like a lambda?) this to v:

  return apply_vector_unary<Container>::apply(
      std::forward<Container>(x), [](auto&& v) { return v.array().exp(); });

I’m trying to avoid this extra “casting” or using apply by using tbb’s parallel_for. I have this mostly compiling, but when I run parallel_for and blocked_range directly on x, the input of the function I get type deduction failure, i.e. here:

tbb::parallel_for(tbb::blocked_range<size_t>(0,N), apply_exp(x));

So I’m wondering if the std::forward and two returns are necessary?

Sometimes it’s good to just ask. I can push to a feature branch, but the code is a bit messy right now.

I have something compiling, nothing to do with above code blocks, but if anyone has comments that’s cool.