|
6 | 6 | //
|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 |
| -// UNSUPPORTED: c++03, c++11, c++17 |
| 9 | +// UNSUPPORTED: c++03, c++11, c++14 |
10 | 10 |
|
11 | 11 | // <ratio>
|
12 | 12 | //
|
|
16 | 16 | // R1 or R2, and the template argument is not a specialization of the
|
17 | 17 | // ratio template, the program is ill-formed.
|
18 | 18 | //
|
19 |
| -// Since std::ratio_xxx uses the same instantiations only one error |
20 |
| -// will be generated. These types are tested in a separate test. |
| 19 | +// Since all std::ratio_xxx_v variables use the same instantiation, only one |
| 20 | +// error will be generated. These values are tested in a separate test. |
21 | 21 |
|
22 | 22 | #include <ratio>
|
23 | 23 |
|
24 |
| -struct R { |
| 24 | +struct invalid { |
25 | 25 | constexpr static int num = 1;
|
26 | 26 | constexpr static int den = 1;
|
27 | 27 | };
|
28 | 28 |
|
29 |
| -using r = std::ratio<1, 1>; |
| 29 | +using valid = std::ratio<1, 1>; |
30 | 30 |
|
31 |
| -namespace equal { |
32 |
| -constexpr bool r_r_v = std::ratio_equal_v<r, r>; |
33 |
| -constexpr bool R_r_v = |
34 |
| - std::ratio_equal_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
35 |
| -constexpr bool r_R_v = |
36 |
| - std::ratio_equal_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
37 |
| -} // namespace equal |
| 31 | +void test() { |
| 32 | + // equal |
| 33 | + (void)std::ratio_equal_v<valid, valid>; |
| 34 | + (void)std::ratio_equal_v<invalid, valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 35 | + (void)std::ratio_equal_v<valid, invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
38 | 36 |
|
39 |
| -namespace not_equal { |
40 |
| -constexpr bool r_r_v = std::ratio_not_equal_v<r, r>; |
41 |
| -constexpr bool R_r_v = |
42 |
| - std::ratio_not_equal_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
43 |
| -constexpr bool r_R_v = |
44 |
| - std::ratio_not_equal_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
45 |
| -} // namespace not_equal |
| 37 | + // not_equal |
| 38 | + (void)std::ratio_not_equal_v<valid, valid>; |
| 39 | + (void)std::ratio_not_equal_v<invalid, |
| 40 | + valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 41 | + (void)std::ratio_not_equal_v<valid, |
| 42 | + invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
46 | 43 |
|
47 |
| -namespace less { |
48 |
| -constexpr bool r_r_v = std::ratio_less_v<r, r>; |
49 |
| -constexpr bool R_r_v = |
50 |
| - std::ratio_less_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
51 |
| -constexpr bool r_R_v = |
52 |
| - std::ratio_less_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
53 |
| -} // namespace less |
| 44 | + // less |
| 45 | + (void)std::ratio_less_v<valid, valid>; |
| 46 | + (void)std::ratio_less_v<invalid, valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 47 | + (void)std::ratio_less_v<valid, invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
54 | 48 |
|
55 |
| -namespace less_equal { |
56 |
| -constexpr bool r_r_v = std::ratio_less_equal_v<r, r>; |
57 |
| -constexpr bool R_r_v = |
58 |
| - std::ratio_less_equal_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
59 |
| -constexpr bool r_R_v = |
60 |
| - std::ratio_less_equal_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
61 |
| -} // namespace less_equal |
| 49 | + // less_equal |
| 50 | + (void)std::ratio_less_equal_v<valid, valid>; |
| 51 | + (void)std::ratio_less_equal_v<invalid, |
| 52 | + valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 53 | + (void)std::ratio_less_equal_v<valid, |
| 54 | + invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
62 | 55 |
|
63 |
| -namespace greater { |
64 |
| -constexpr bool r_r_v = std::ratio_greater_v<r, r>; |
65 |
| -constexpr bool R_r_v = |
66 |
| - std::ratio_greater_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
67 |
| -constexpr bool r_R_v = |
68 |
| - std::ratio_greater_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
69 |
| -} // namespace greater |
| 56 | + // greater |
| 57 | + (void)std::ratio_greater_v<valid, valid>; |
| 58 | + (void)std::ratio_greater_v<invalid, valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 59 | + (void)std::ratio_greater_v<valid, invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
70 | 60 |
|
71 |
| -namespace greater_equal { |
72 |
| -constexpr bool r_r_v = std::ratio_greater_equal_v<r, r>; |
73 |
| -constexpr bool R_r_v = |
74 |
| - std::ratio_greater_equal_v<R, r>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
75 |
| -constexpr bool r_R_v = |
76 |
| - std::ratio_greater_equal_v<r, R>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
77 |
| -} // namespace greater_equal |
| 61 | + // greater_equal |
| 62 | + (void)std::ratio_greater_equal_v<valid, valid>; |
| 63 | + |
| 64 | + (void)std::ratio_greater_equal_v<invalid, |
| 65 | + valid>; // expected-error@*:* {{R1 to be a specialisation of the ratio template}} |
| 66 | + |
| 67 | + (void)std::ratio_greater_equal_v<valid, |
| 68 | + invalid>; // expected-error@*:* {{R2 to be a specialisation of the ratio template}} |
| 69 | +} |
0 commit comments