| 1 |
// PR c++/100557 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
template <typename _Tp> _Tp declval(); |
| 5 |
|
| 6 |
struct print_tag_; |
| 7 |
|
| 8 |
bool tag_invoke(print_tag_, auto); |
| 9 |
bool tag_invoke(print_tag_, auto obj) requires requires { *obj; }; |
| 10 |
|
| 11 |
template <typename CPO, typename... Args> |
| 12 |
auto try_tag_invoke() noexcept(tag_invoke(declval<CPO>, declval<Args>()...)) // { dg-error "no matching function for call" } |
| 13 |
-> decltype(tag_invoke(CPO(), declval<Args>()...)); |
| 14 |
|
| 15 |
struct print_tag_ { |
| 16 |
void operator()(auto... args) noexcept(noexcept( try_tag_invoke<print_tag_, decltype(args)...>())); |
| 17 |
} print; |
| 18 |
|
| 19 |
void foo() { |
| 20 |
print(0); |
| 21 |
} |