How can we forward a function auto parameter using std::forward for the below code?
void push_value(std::vector<MyType>& vec, auto&& value)
{
vec.emplace_back(std::forward<?>(value));
}
You want decltype(value)(value)
(without forward
).
Some prefer to write std::forward<decltype(value)>(value)
, but it does exactly the same thing, the forward
is superfluous.