| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
// { dg-options "-fconcepts" } |
| 3 |
// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" } |
| 4 |
|
| 5 |
struct dog{}; |
| 6 |
struct cat{}; |
| 7 |
|
| 8 |
void pet(dog); |
| 9 |
void pet(cat); |
| 10 |
|
| 11 |
template <class T> |
| 12 |
concept pettable = requires(T t) { t.pet(); }; |
| 13 |
|
| 14 |
template <pettable T> |
| 15 |
void pet(T); |
| 16 |
|
| 17 |
struct donkey {}; |
| 18 |
|
| 19 |
int main() { |
| 20 |
pet(donkey{}); // { dg-error "no matching function for call to 'pet\\\(donkey\\\)'" } |
| 21 |
} |
| 22 |
|
| 23 |
/* { dg-begin-multiline-output "" } |
| 24 |
* there are 3 candidates |
| 25 |
* candidate 1: 'template<class T> requires pettable<T> void pet(T)' |
| 26 |
* template argument deduction/substitution failed: |
| 27 |
* constraints not satisfied |
| 28 |
* In substitution of 'template<class T> requires pettable<T> void pet(T) [with T = donkey]': |
| 29 |
* required from here |
| 30 |
* required for the satisfaction of 'pettable<T>' [with T = donkey] |
| 31 |
* in requirements with 'T t' [with T = donkey] |
| 32 |
* the required expression 't.pet()' is invalid |
| 33 |
* set '-fconcepts-diagnostics-depth=' to at least 2 for more detail |
| 34 |
* candidate 2: 'void pet(dog)' |
| 35 |
* no known conversion for argument 1 from 'donkey' to 'dog' |
| 36 |
* candidate 3: 'void pet(cat)' |
| 37 |
* no known conversion for argument 1 from 'donkey' to 'cat' |
| 38 |
{ dg-end-multiline-output "" } */ |