I have come across two variants of std::forward
usage with variadic template arguments.
template <typename... Args>
void foo(Args&&... arga)
{
bar(std::forward<Args>(args)...); // variant 1
bar(std::forward<Args...>(args)...); // variant 2
// EDIT the above is a fixed version, the initial incorrect version was
// bar(std::forward<Args>(args...)); // variant 1
// bar(std::forward<Args...>(args...)); // variant 2
}
I have tried both variants with g++ and clang, and both appear to work equally well. No warnings produced with -Wall -Wextra -Wpedantic
.
Are both variants correct? If not, why not? What does the standard have to say about it?