brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.1 KiB · 07ea511 Raw
148 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++14, c++1710 11// <utility>12 13// template<class T, class U>14//   constexpr bool cmp_equal(T t, U u) noexcept; // C++2015 16// template<class T, class U>17//   constexpr bool cmp_not_equal(T t, U u) noexcept; // C++2018 19// template<class T, class U>20//   constexpr bool cmp_less(T t, U u) noexcept; // C++2021 22// template<class T, class U>23//   constexpr bool cmp_less_equal(T t, U u) noexcept; // C++2024 25// template<class T, class U>26//   constexpr bool cmp_greater(T t, U u) noexcept; // C++2027 28// template<class T, class U>29//   constexpr bool cmp_greater_equal(T t, U u) noexcept; // C++2030 31// template<class R, class T>32//   constexpr bool in_range(T t) noexcept;      // C++2033 34#include <utility>35#include <cstddef>36 37#include "test_macros.h"38 39struct NonEmptyT {40  int val;41  NonEmptyT() : val(0) {}42  NonEmptyT(int val) : val(val) {}43  operator int&() { return val; }44  operator int() const { return val; }45};46 47enum ColorT { red, green, blue };48 49struct EmptyT {};50 51template <class T>52constexpr void test() {53  std::cmp_equal(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_equal'}}54  std::cmp_equal(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_equal'}}55  std::cmp_equal(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_equal'}}56  std::cmp_not_equal(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_not_equal'}}57  std::cmp_not_equal(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_not_equal'}}58  std::cmp_not_equal(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_not_equal'}}59  std::cmp_less(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_less'}}60  std::cmp_less(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_less'}}61  std::cmp_less(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_less'}}62  std::cmp_less_equal(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_less_equal'}}63  std::cmp_less_equal(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_less_equal'}}64  std::cmp_less_equal(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_less_equal'}}65  std::cmp_greater(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_greater'}}66  std::cmp_greater(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_greater'}}67  std::cmp_greater(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_greater'}}68  std::cmp_greater_equal(T(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_greater_equal'}}69  std::cmp_greater_equal(T(), int()); // expected-error 10-11 {{no matching function for call to 'cmp_greater_equal'}}70  std::cmp_greater_equal(int(), T()); // expected-error 10-11 {{no matching function for call to 'cmp_greater_equal'}}71  std::in_range<T>(int()); // expected-error 10-11 {{no matching function for call to 'in_range'}}72  std::in_range<int>(T()); // expected-error 10-11 {{no matching function for call to 'in_range'}}73}74#ifndef TEST_HAS_NO_CHAR8_T75template <class T>76constexpr void test_char8t() {77  std::cmp_equal(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_equal'}}78  std::cmp_equal(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_equal'}}79  std::cmp_equal(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_equal'}}80  std::cmp_not_equal(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_not_equal'}}81  std::cmp_not_equal(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_not_equal'}}82  std::cmp_not_equal(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_not_equal'}}83  std::cmp_less(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_less'}}84  std::cmp_less(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_less'}}85  std::cmp_less(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_less'}}86  std::cmp_less_equal(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_less_equal'}}87  std::cmp_less_equal(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_less_equal'}}88  std::cmp_less_equal(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_less_equal'}}89  std::cmp_greater(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_greater'}}90  std::cmp_greater(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_greater'}}91  std::cmp_greater(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_greater'}}92  std::cmp_greater_equal(T(), T()); // expected-error 1 {{no matching function for call to 'cmp_greater_equal'}}93  std::cmp_greater_equal(T(), int()); // expected-error 1 {{no matching function for call to 'cmp_greater_equal'}}94  std::cmp_greater_equal(int(), T()); // expected-error 1 {{no matching function for call to 'cmp_greater_equal'}}95  std::in_range<T>(int()); // expected-error 1 {{no matching function for call to 'in_range'}}96  std::in_range<int>(T()); // expected-error 1 {{no matching function for call to 'in_range'}}97}98#endif // TEST_HAS_NO_CHAR8_T99 100template <class T>101constexpr void test_uchars() {102  std::cmp_equal(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_equal'}}103  std::cmp_equal(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_equal'}}104  std::cmp_equal(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_equal'}}105  std::cmp_not_equal(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_not_equal'}}106  std::cmp_not_equal(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_not_equal'}}107  std::cmp_not_equal(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_not_equal'}}108  std::cmp_less(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_less'}}109  std::cmp_less(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_less'}}110  std::cmp_less(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_less'}}111  std::cmp_less_equal(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_less_equal'}}112  std::cmp_less_equal(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_less_equal'}}113  std::cmp_less_equal(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_less_equal'}}114  std::cmp_greater(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_greater'}}115  std::cmp_greater(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_greater'}}116  std::cmp_greater(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_greater'}}117  std::cmp_greater_equal(T(), T()); // expected-error 2 {{no matching function for call to 'cmp_greater_equal'}}118  std::cmp_greater_equal(T(), int()); // expected-error 2 {{no matching function for call to 'cmp_greater_equal'}}119  std::cmp_greater_equal(int(), T()); // expected-error 2 {{no matching function for call to 'cmp_greater_equal'}}120  std::in_range<T>(int()); // expected-error 2 {{no matching function for call to 'in_range'}}121  std::in_range<int>(T()); // expected-error 2 {{no matching function for call to 'in_range'}}122}123 124int main(int, char**) {125  test<bool>();126  test<char>();127#ifndef TEST_HAS_NO_WIDE_CHARACTERS128  test<wchar_t>();129#endif130  test<float>();131  test<double>();132  test<long double>();133  test<std::byte>();134  test<NonEmptyT>();135  test<ColorT>();136  test<std::nullptr_t>();137  test<EmptyT>();138 139#ifndef TEST_HAS_NO_CHAR8_T140  test_char8t<char8_t>();141#endif // TEST_HAS_NO_CHAR8_T142 143  test_uchars<char16_t>();144  test_uchars<char32_t>();145 146  return 0;147}148