blob: 04e7ee6f892f2bef33949507131fa02662baf0cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// { dg-do compile { target c++20 } }
template<typename T>
concept True = true;
template<typename T>
concept False = false;
template<typename T>
concept Int = __is_same_as(T, int);
static_assert(True<int>);
static_assert(!False<int>);
static_assert(False<int>); // { dg-error "static assertion failed" }
constexpr bool will_be_true() {
if (True<int>)
return true;
return false;
}
constexpr bool will_be_false() {
if (!False<int>)
return true;
return false;
}
static_assert(will_be_true());
static_assert(will_be_false());
template<typename T>
constexpr bool is_int() {
if (Int<T>)
return true;
return false;
}
static_assert(is_int<int>());
static_assert(is_int<void>()); // { dg-error "static assertion failed" }
template<typename T>
constexpr bool f1() {
if (Int<int>) // Note: always true.
return true;
return false;
}
static_assert(f1<int>());
static_assert(f1<void>());
template<typename T>
constexpr bool f2() {
if constexpr (Int<int>) // Note: always true.
return true;
return false;
}
static_assert(f2<int>());
static_assert(f2<void>());
template<typename T>
concept C = true;
int driver() {
bool c_int = (C<int>);
if((C<int>))
;
return c_int;
}
|