brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · fbcf358 Raw
70 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <ratio>12//13// [ratio.general]/214//   Throughout subclause [ratio], the names of template parameters are15//   used to express type requirements. If a template parameter is named16//   R1 or R2, and the template argument is not a specialization of the17//   ratio template, the program is ill-formed.18//19// Since all std::ratio_xxx_v variables use the same instantiation, only one20// error will be generated. These values are tested in a separate test.21 22#include <ratio>23 24struct invalid {25  constexpr static int num = 1;26  constexpr static int den = 1;27};28 29using valid = std::ratio<1, 1>;30 31void test() {32  // equal33  (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}}36 37  // not_equal38  (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}}43 44  // less45  (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}}48 49  // less_equal50  (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}}55 56  // greater57  (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}}60 61  // greater_equal62  (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}70