| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
// { dg-options "-fconcepts" } |
| 3 |
|
| 4 |
template<class T, class U> concept same_as = __is_same(T, U); |
| 5 |
template <class X> concept allocatable = requires{{new X}->same_as<X *>; }; |
| 6 |
template <class X> concept semiregular = allocatable<X>; |
| 7 |
template <class X> concept readable = requires{requires semiregular<X>;}; |
| 8 |
template <class> int weak_input_iterator = requires{{0}->readable;}; |
| 9 |
template <class X> bool input_iterator{weak_input_iterator<X>}; // { dg-prune-output "narrowing conversion" } |
| 10 |
template <class X> bool forward_iterator{input_iterator<X>}; |
| 11 |
template <class X> bool bidirectional_iterator{forward_iterator<X>}; |
| 12 |
template <class X> |
| 13 |
concept random_access_iterator = bidirectional_iterator<X>; // { dg-error "constant" } |
| 14 |
void fn1(random_access_iterator auto); |
| 15 |
int main() { fn1(0); } // { dg-error "" } |