| 1 |
// PR c++/118698 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
template <typename T> struct foo {}; |
| 5 |
template <typename T> struct bar {}; |
| 6 |
|
| 7 |
template <class T> T&& declval (); |
| 8 |
|
| 9 |
template <typename T, typename U> |
| 10 |
concept callable = requires { declval<T>()(declval<U>()); }; |
| 11 |
|
| 12 |
template <typename T, template <typename...> typename U> |
| 13 |
concept is_specialization_of = callable<decltype([]<typename... Args>( U<Args...> const& ) { }),T>; |
| 14 |
|
| 15 |
static_assert( is_specialization_of<foo<int>,foo> == true ); |
| 16 |
static_assert( is_specialization_of<foo<int>,bar> == false ); |
| 17 |
|
| 18 |
template <typename T> concept is_foo = is_specialization_of<T,foo>; |
| 19 |
|
| 20 |
static_assert( is_foo<foo<int>> ); |
| 21 |
static_assert( is_foo<bar<int>> == false ); |