On the following code
#include <utility>
template <int i = 0, class F, typename... ArgsType>
void g(F&& f, ArgsType&&... args)
{
if constexpr (i < 1) {
f(std::forward<ArgsType>(args)...);
g<1>(std::forward<F>(f), std::forward<ArgsType>(args)...);
}
}
a run of cppcheck --enable=all
gives the following warning:
Checking test.hpp ...
test.hpp:8:53: warning: Access of forwarded variable 'args'. [accessForwarded]
g<1>(std::forward<F>(f), std::forward<ArgsType>(args)...);
^
test.hpp:7:7: note: Calling std::forward(args)
f(std::forward<ArgsType>(args)...);
^
test.hpp:8:53: note: Access of forwarded variable 'args'.
g<1>(std::forward<F>(f), std::forward<ArgsType>(args)...);
^
What does this warning mean and why is it triggered?