| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
// { dg-additional-options -fconcepts } |
| 3 |
|
| 4 |
// Don't attach constraints to block-scope fn-decls and ICE |
| 5 |
|
| 6 |
template<typename _Iter> |
| 7 |
concept input_or_output_iterator |
| 8 |
= requires(_Iter __i) { { *__i } ; }; |
| 9 |
|
| 10 |
|
| 11 |
template<input_or_output_iterator _It> |
| 12 |
class common_iterator |
| 13 |
{ |
| 14 |
|
| 15 |
public: |
| 16 |
|
| 17 |
void |
| 18 |
frob () |
| 19 |
{ |
| 20 |
if (__builtin_is_constant_evaluated()) |
| 21 |
{ |
| 22 |
void __failed_assertion(); // ICEd |
| 23 |
if (!bool(_M_index == 0)) __failed_assertion(); |
| 24 |
} |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
private: |
| 29 |
unsigned char _M_index; |
| 30 |
}; |
| 31 |
|
| 32 |
template <typename T> concept C = true; |
| 33 |
|
| 34 |
template<typename T> |
| 35 |
void F () |
| 36 |
{ |
| 37 |
void bad () requires C<T>; // { dg-error "a non-templated function" } |
| 38 |
|
| 39 |
} |