Skip to content

Commit 1c18400

Browse files
committed
address review comments.
1 parent e982e81 commit 1c18400

File tree

3 files changed

+101
-87
lines changed

3 files changed

+101
-87
lines changed

libcxx/test/std/utilities/ratio/ratio.arithmetic/R1_R2_requirement.verify.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,44 @@
1313
// used to express type requirements. If a template parameter is named
1414
// R1 or R2, and the template argument is not a specialization of the
1515
// ratio template, the program is ill-formed.
16-
//
17-
// test ratio_multiply
1816

1917
#include <ratio>
2018

21-
struct R {
19+
struct invalid {
2220
static const int num = 1;
2321
static const int den = 1;
2422
};
2523

26-
using r = std::ratio<1, 1>;
24+
using valid = std::ratio<1, 1>;
2725

2826
namespace add {
29-
using r_r = std::ratio_add<r, r>::type;
30-
using R_r = std::ratio_add<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
31-
using r_R = std::ratio_add<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
27+
using valid_valid = std::ratio_add<valid, valid>::type;
28+
using invalid_valid =
29+
std::ratio_add<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
30+
using valid_invalid =
31+
std::ratio_add<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
3232
} // namespace add
3333

3434
namespace subtract {
35-
using r_r = std::ratio_subtract<r, r>::type;
36-
using R_r = std::ratio_subtract<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
37-
using r_R = std::ratio_subtract<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
35+
using valid_valid = std::ratio_subtract<valid, valid>::type;
36+
using invalid_valid =
37+
std::ratio_subtract<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
38+
using valid_invalid =
39+
std::ratio_subtract<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
3840
} // namespace subtract
3941

4042
namespace multiply {
41-
using r_r = std::ratio_multiply<r, r>::type;
42-
using R_r = std::ratio_multiply<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
43-
using r_R = std::ratio_multiply<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
43+
using valid_valid = std::ratio_multiply<valid, valid>::type;
44+
using invalid_valid =
45+
std::ratio_multiply<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
46+
using valid_invalid =
47+
std::ratio_multiply<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
4448
} // namespace multiply
4549

4650
namespace divide {
47-
using r_r = std::ratio_divide<r, r>::type;
48-
using R_r = std::ratio_divide<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
49-
using r_R = std::ratio_divide<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
51+
using valid_valid = std::ratio_divide<valid, valid>::type;
52+
using invalid_valid =
53+
std::ratio_divide<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
54+
using valid_invalid =
55+
std::ratio_divide<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
5056
} // namespace divide

libcxx/test/std/utilities/ratio/ratio.comparison/R1_R2_requirement.verify.cpp

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,68 @@
1414
// R1 or R2, and the template argument is not a specialization of the
1515
// ratio template, the program is ill-formed.
1616
//
17-
// Since std::ratio_xxx_v uses the same instantiations only one error
18-
// will be generated. These values are tested in a separate test.
17+
// Since all std::ratio_xxx_v variables use the same instantiation, only one
18+
// error will be generated. These values are tested in a separate test.
1919

2020
#include <ratio>
2121

22-
struct R {
22+
struct invalid {
2323
static const int num = 1;
2424
static const int den = 1;
2525
};
2626

27-
using r = std::ratio<1, 1>;
27+
using valid = std::ratio<1, 1>;
2828

2929
namespace equal {
30-
using r_r = std::ratio_equal<r, r>::type;
31-
using R_r = std::ratio_equal<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
32-
using r_R = std::ratio_equal<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
30+
using valid_valid = std::ratio_equal<valid, valid>::type;
31+
using invalid_valid =
32+
std::ratio_equal<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
33+
using valid_invalid =
34+
std::ratio_equal<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
3335
} // namespace equal
3436

3537
namespace not_equal {
36-
using r_r = std::ratio_not_equal<r, r>::type;
37-
using R_r = std::ratio_not_equal<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
38-
using r_R = std::ratio_not_equal<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
38+
using valid_valid = std::ratio_not_equal<valid, valid>::type;
39+
using invalid_valid =
40+
std::ratio_not_equal<invalid,
41+
valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
42+
using valid_invalid =
43+
std::ratio_not_equal<valid,
44+
invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
3945
} // namespace not_equal
4046

4147
namespace less {
42-
using r_r = std::ratio_less<r, r>::type;
43-
using R_r = std::ratio_less<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
44-
using r_R = std::ratio_less<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
48+
using valid_valid = std::ratio_less<valid, valid>::type;
49+
using invalid_valid =
50+
std::ratio_less<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
51+
using valid_invalid =
52+
std::ratio_less<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
4553
} // namespace less
4654

4755
namespace less_equal {
48-
using r_r = std::ratio_less_equal<r, r>::type;
49-
using R_r = std::ratio_less_equal<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
50-
using r_R = std::ratio_less_equal<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
56+
using valid_valid = std::ratio_less_equal<valid, valid>::type;
57+
using invalid_valid =
58+
std::ratio_less_equal<invalid,
59+
valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
60+
using valid_invalid =
61+
std::ratio_less_equal<valid,
62+
invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
5163
} // namespace less_equal
5264

5365
namespace greater {
54-
using r_r = std::ratio_greater<r, r>::type;
55-
using R_r = std::ratio_greater<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
56-
using r_R = std::ratio_greater<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
66+
using valid_valid = std::ratio_greater<valid, valid>::type;
67+
using invalid_valid =
68+
std::ratio_greater<invalid, valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
69+
using valid_invalid =
70+
std::ratio_greater<valid, invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
5771
} // namespace greater
5872

5973
namespace greater_equal {
60-
using r_r = std::ratio_greater_equal<r, r>::type;
61-
using R_r =
62-
std::ratio_greater_equal<R, r>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
63-
using r_R =
64-
std::ratio_greater_equal<r, R>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
74+
using valid_valid = std::ratio_greater_equal<valid, valid>::type;
75+
using invalid_valid =
76+
std::ratio_greater_equal<invalid,
77+
valid>::type; // expected-error@*:* {{R1 to be a specialisation of the ratio template}}
78+
using valid_invalid =
79+
std::ratio_greater_equal<valid,
80+
invalid>::type; // expected-error@*:* {{R2 to be a specialisation of the ratio template}}
6581
} // namespace greater_equal

libcxx/test/std/utilities/ratio/ratio.comparison/R1_R2_requirement_v.verify.cpp

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++17
9+
// UNSUPPORTED: c++03, c++11, c++14
1010

1111
// <ratio>
1212
//
@@ -16,62 +16,54 @@
1616
// R1 or R2, and the template argument is not a specialization of the
1717
// ratio template, the program is ill-formed.
1818
//
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.
2121

2222
#include <ratio>
2323

24-
struct R {
24+
struct invalid {
2525
constexpr static int num = 1;
2626
constexpr static int den = 1;
2727
};
2828

29-
using r = std::ratio<1, 1>;
29+
using valid = std::ratio<1, 1>;
3030

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}}
3836

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}}
4643

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}}
5448

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}}
6255

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}}
7060

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

Comments
 (0)