1// RUN: %check_clang_tidy -std=c++14 %s cppcoreguidelines-missing-std-forward %t -- \
2// RUN: -config="{CheckOptions: {cppcoreguidelines-missing-std-forward.ForwardFunction: custom_forward}}" -- -fno-delayed-template-parsing
3
4// NOLINTBEGIN
5namespace std {
6
7template <typename T> struct remove_reference { using type = T; };
8template <typename T> struct remove_reference<T&> { using type = T; };
9template <typename T> struct remove_reference<T&&> { using type = T; };
10
11template <typename T> using remove_reference_t = typename remove_reference<T>::type;
12
13template <typename T> constexpr T &&forward(remove_reference_t<T> &t) noexcept;
14template <typename T> constexpr T &&forward(remove_reference_t<T> &&t) noexcept;
15template <typename T> constexpr remove_reference_t<T> &&move(T &&x);
16
17} // namespace std
18// NOLINTEND
19
20template<class T>
21constexpr decltype(auto) custom_forward(std::remove_reference_t<T>& tmp) noexcept
22{
23 return static_cast<T&&>(tmp);
24}
25
26template<class T>
27constexpr decltype(auto) custom_forward(std::remove_reference_t<T>&& tmp) noexcept
28{
29 return static_cast<T&&>(tmp);
30}
31
32template<class T>
33void forward_with_std(T&& t) {
34 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
35
36 T other{std::forward<T>(t)};
37}
38
39template<class T>
40void move_with_custom(T&& t) {
41 T other{custom_forward<T>(t)};
42}
43

source code of clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward-custom-function.cpp