// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-avoid-bind %t -- \ // RUN: -config="{CheckOptions: [ \ // RUN: {key: modernize-avoid-bind.PermissiveParameterList, value: 1}]}" -- namespace std { inline namespace impl { template class bind_rt {}; template bind_rt bind(Fp &&, Arguments &&...); } // namespace impl template T ref(T &t); } // namespace std int add(int x, int y) { return x + y; } // Let's fake a minimal std::function-like facility. namespace std { template _Tp declval(); template struct __res { template static decltype(declval<_Functor>()(_Args()...)) _S_test(int); template static void _S_test(...); using type = decltype(_S_test<_ArgTypes...>(0)); }; template struct function; template struct function { template ::type> function(_Functor) {} }; } // namespace std struct placeholder {}; placeholder _1; void testLiteralParameters() { auto AAA = std::bind(add, 2, 2); // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind] // CHECK-FIXES: auto AAA = [](auto && ...) { return add(2, 2); }; auto BBB = std::bind(add, _1, 2); // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind] // CHECK-FIXES: auto BBB = [](auto && PH1, auto && ...) { return add(PH1, 2); }; }