1.. title:: clang-tidy - cppcoreguidelines-missing-std-forward 2 3cppcoreguidelines-missing-std-forward 4===================================== 5 6Warns when a forwarding reference parameter is not forwarded inside the 7function body. 8 9Example: 10 11.. code-block:: c++ 12 13 template <class T> 14 void wrapper(T&& t) { 15 impl(std::forward<T>(t), 1, 2); // Correct 16 } 17 18 template <class T> 19 void wrapper2(T&& t) { 20 impl(t, 1, 2); // Oops - should use std::forward<T>(t) 21 } 22 23 template <class T> 24 void wrapper3(T&& t) { 25 impl(std::move(t), 1, 2); // Also buggy - should use std::forward<T>(t) 26 } 27 28 template <class F> 29 void wrapper_function(F&& f) { 30 std::forward<F>(f)(1, 2); // Correct 31 } 32 33 template <class F> 34 void wrapper_function2(F&& f) { 35 f(1, 2); // Incorrect - may not invoke the desired qualified function operator 36 } 37 38This check implements `F.19 39<http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-forward>`_ 40from the C++ Core Guidelines. 41