1 // { dg-do compile { target c++2a } } 2 // { dg-additional-options "-fconcepts-ts" } 3 4 // This tests the terse notation. 5 6 template<typename T> 7 concept True = true; 8 9 template<typename T> 10 concept False = false; 11 12 template<typename T, typename U> 13 concept SameAs = __is_same_as(T, U); 14 15 True x1 = 0; 16 False x2 = 0; // { dg-error "deduced initializer does not satisfy" } 17 f1(True t)18void f1(True t) { } f2(False t)19void f2(False t) { } f3(SameAs<int> q)20void f3(SameAs<int> q) { } f4(True a,SameAs<decltype (a)> b)21void f4(True a, SameAs<decltype(a)> b) { } 22 f5()23True f5() { return 0; } f6()24False f6() { return 0; } // { dg-error "deduced return type" } f7()25SameAs<int> f7() { return 0; } f8()26SameAs<int> f8() { return 'a'; } // { dg-error "deduced return type" } 27 auto f9() -> True { return 0; } 28 auto f10() -> False { return 0; } // { dg-error "deduced return type" } 29 auto f11() -> SameAs<int> { return 0; } 30 auto f12() -> SameAs<char> { return 0; } // { dg-error "deduced return type" } 31 auto f13(int n) -> SameAs<decltype(n)> { return n; } 32 auto f14(int n) -> SameAs<decltype(n)> { return 'a'; } // { dg-error "deduced return type" } 33 auto f15(auto x) -> SameAs<decltype(x)> { return 0; } // { dg-error "deduced return type" } 34 driver()35void driver() 36 { 37 f1(0); 38 f2(0); // { dg-error "" } 39 f3(0); 40 f3('a'); // { dg-error "" } 41 f4(0, 0); 42 f4(0, 'a'); // { dg-error "" } 43 f15(0); 44 f15('a'); // { dg-message "" } 45 } 46 C1()47template<class T> concept bool C1() { return false; } C2()48template<C1 T> concept bool C2() { return true; } // { dg-error "cannot be constrained" } 49 template<C1 T> concept bool C3 = true; // { dg-error "cannot be constrained" } 50