Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/concepts/dr1430.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // PR c++/66092 | |
2 // { dg-options "-std=c++17 -fconcepts" } | |
3 | |
4 #include <type_traits> | |
5 | |
6 template <typename T, typename U, typename... Args> | |
7 requires (sizeof...(Args) == 0) | |
8 constexpr decltype(auto) check() | |
9 { | |
10 return std::integral_constant<bool, __is_same_as(T, U)>(); | |
11 } | |
12 | |
13 template <typename T, typename U, typename... Args> | |
14 requires (sizeof...(Args) > 0) | |
15 constexpr decltype(auto) check() | |
16 { | |
17 return std::integral_constant<bool, __is_same_as(T, U) | |
18 && decltype(check<U, Args...>())::value>(); | |
19 } | |
20 | |
21 template <typename T, typename U, typename... Args> | |
22 concept bool Same() | |
23 { | |
24 return decltype(check<T, U, Args...>())::value; | |
25 } | |
26 | |
27 template <typename T, typename U, typename... Args> | |
28 concept bool Similar = true; | |
29 | |
30 template <typename... Args> | |
31 requires Same<Args...>() // { dg-error "invalid reference" } | |
32 void foo( Args... args ) {} | |
33 | |
34 template <typename... Args> | |
35 requires Similar<Args...> // { dg-error "invalid reference" } | |
36 void bar( Args... args ) {} | |
37 | |
38 int main() | |
39 { | |
40 foo(1, 2, 3); // { dg-error "cannot call" } | |
41 bar(1, 2, 3); // { dg-error "cannot call" } | |
42 } |