tidy - cppcoreguidelines-missing-std-forward — Extra Clang Tools 22.0.0git documentation (original) (raw)

Warns when a forwarding reference parameter is not forwarded inside the function body.

Example:

template void wrapper(T&& t) { impl(std::forward(t), 1, 2); // Correct }

template void wrapper2(T&& t) { impl(t, 1, 2); // Oops - should use std::forward(t) }

template void wrapper3(T&& t) { impl(std::move(t), 1, 2); // Also buggy - should use std::forward(t) }

template void wrapper_function(F&& f) { std::forward(f)(1, 2); // Correct }

template void wrapper_function2(F&& f) { f(1, 2); // Incorrect - may not invoke the desired qualified function operator }

Options

ForwardFunction

Specify the function used for forwarding. Default is ::std::forward.

This check implements F.19from the C++ Core Guidelines.