1 // PR c++/66092
2 // { dg-do compile { target c++17 } }
3 // { dg-options "-fconcepts" }
4 
5 #include <type_traits>
6 
7 template <typename T, typename U, typename... Args>
8 requires (sizeof...(Args) == 0)
decltype(auto)9   constexpr decltype(auto) check()
10   {
11     return std::integral_constant<bool, __is_same_as(T, U)>();
12   }
13 
14 template <typename T, typename U, typename... Args>
15 requires (sizeof...(Args) > 0)
decltype(auto)16   constexpr decltype(auto) check()
17   {
18     return std::integral_constant<bool, __is_same_as(T, U)
19         && decltype(check<U, Args...>())::value>();
20   }
21 
22 template <typename T, typename U, typename... Args>
Same()23   concept bool Same()
24   {
25     return decltype(check<T, U, Args...>())::value;
26   }
27 
28 template <typename T, typename U, typename... Args>
29   concept bool Similar = true;
30 
31 template <typename... Args>
32 requires Same<Args...>() // { dg-error "invalid reference" }
foo(Args...args)33   void foo( Args... args ) {}
34 
35 template <typename... Args>
36 requires Similar<Args...> // { dg-error "invalid reference" }
bar(Args...args)37   void bar( Args... args ) {}
38 
main()39 int main()
40 {
41   foo(1, 2, 3); // { dg-error "cannot call" }
42   bar(1, 2, 3); // { dg-error "cannot call" }
43 }
44