| 1 | // RUN: %check_clang_tidy -std=c++20-or-later %s bugprone-forwarding-reference-overload %t |
| 2 | |
| 3 | template <typename T> constexpr bool just_true = true; |
| 4 | |
| 5 | class Test { |
| 6 | public: |
| 7 | template <typename T> Test(T &&n); |
| 8 | // CHECK-NOTES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding reference can hide the copy and move constructors |
| 9 | |
| 10 | Test(const Test &rhs); |
| 11 | // CHECK-NOTES: :[[@LINE-1]]:3: note: copy constructor declared here |
| 12 | }; |
| 13 | |
| 14 | class Test1 { |
| 15 | public: |
| 16 | // Guarded with requires expression. |
| 17 | template <typename T> |
| 18 | requires requires { just_true<T>; } |
| 19 | Test1(T &&n); |
| 20 | }; |
| 21 | |
| 22 | template<typename T> |
| 23 | concept JustTrueConcept = requires { just_true<T>; }; |
| 24 | |
| 25 | class Test2 { |
| 26 | public: |
| 27 | // Guarded with concept requirement. |
| 28 | template <JustTrueConcept T> Test2(T &&n); |
| 29 | }; |
| 30 | |