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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #ifndef SUPPORT_USER_DEFINED_INTEGRAL_H 9 #define SUPPORT_USER_DEFINED_INTEGRAL_H 10 11 #include "test_macros.h" 12 13 template <class T> 14 struct UserDefinedIntegral 15 { UserDefinedIntegralUserDefinedIntegral16 TEST_CONSTEXPR_CXX14 UserDefinedIntegral() : value(0) {} UserDefinedIntegralUserDefinedIntegral17 TEST_CONSTEXPR_CXX14 UserDefinedIntegral(T v) : value(v) {} TUserDefinedIntegral18 TEST_CONSTEXPR_CXX14 operator T() const { return value; } 19 T value; 20 }; 21 22 // Poison the arithmetic and comparison operations 23 template <class T, class U> 24 void operator+(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 25 26 template <class T, class U> 27 void operator-(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 28 29 template <class T, class U> 30 void operator*(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 31 32 template <class T, class U> 33 void operator/(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 34 35 template <class T, class U> 36 void operator==(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 37 38 template <class T, class U> 39 void operator!=(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 40 41 template <class T, class U> 42 void operator<(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 43 44 template <class T, class U> 45 void operator>(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 46 47 template <class T, class U> 48 void operator<=(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 49 50 template <class T, class U> 51 void operator>=(UserDefinedIntegral<T>, UserDefinedIntegral<U>); 52 53 #endif // SUPPORT_USER_DEFINED_INTEGRAL_H 54