brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · c2af123 Raw
48 lines · plain
1.. title:: clang-tidy - cppcoreguidelines-missing-std-forward2 3cppcoreguidelines-missing-std-forward4=====================================5 6Warns when a forwarding reference parameter is not forwarded inside the7function 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); // Correct16  }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); // Correct31  }32 33  template <class F>34  void wrapper_function2(F&& f) {35    f(1, 2); // Incorrect - may not invoke the desired qualified function operator36  }37 38Options39-------40 41.. option:: ForwardFunction42 43   Specify the function used for forwarding. Default is `::std::forward`.44 45This check implements `F.1946<http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#rf-forward>`_47from the C++ Core Guidelines.48