File indexing completed on 2025-01-18 09:51:36
0001 #ifndef BOOST_SAFE_NUMERICS_NATIVE_HPP
0002 #define BOOST_SAFE_NUMERICS_NATIVE_HPP
0003
0004
0005
0006
0007
0008
0009
0010 #include <type_traits>
0011 #include <limits>
0012
0013
0014
0015
0016 namespace boost {
0017 namespace safe_numerics {
0018
0019 struct native {
0020 public:
0021
0022 template<typename T, typename U>
0023 struct addition_result {
0024 using type = decltype(
0025 typename base_type<T>::type()
0026 + typename base_type<U>::type()
0027 );
0028 };
0029 template<typename T, typename U>
0030 struct subtraction_result {
0031 using type = decltype(
0032 typename base_type<T>::type()
0033 - typename base_type<U>::type()
0034 );
0035 };
0036 template<typename T, typename U>
0037 struct multiplication_result {
0038 using type = decltype(
0039 typename base_type<T>::type()
0040 * typename base_type<U>::type()
0041 );
0042 };
0043 template<typename T, typename U>
0044 struct division_result {
0045 using type = decltype(
0046 typename base_type<T>::type()
0047 / typename base_type<U>::type()
0048 );
0049 };
0050 template<typename T, typename U>
0051 struct modulus_result {
0052 using type = decltype(
0053 typename base_type<T>::type()
0054 % typename base_type<U>::type()
0055 );
0056 };
0057
0058
0059
0060 template<typename T, typename U>
0061 struct comparison_result {
0062 using type = decltype(
0063 typename base_type<T>::type()
0064 + typename base_type<U>::type()
0065 );
0066 };
0067
0068
0069 template<typename T, typename U>
0070 struct left_shift_result {
0071 using type = decltype(
0072 typename base_type<T>::type()
0073 << typename base_type<U>::type()
0074 );
0075 };
0076 template<typename T, typename U>
0077 struct right_shift_result {
0078 using type = decltype(
0079 typename base_type<T>::type()
0080 >> typename base_type<U>::type()
0081 );
0082 };
0083
0084 template<typename T, typename U>
0085 struct bitwise_or_result {
0086 using type = decltype(
0087 typename base_type<T>::type()
0088 | typename base_type<U>::type()
0089 );
0090 };
0091 template<typename T, typename U>
0092 struct bitwise_and_result {
0093 using type = decltype(
0094 typename base_type<T>::type()
0095 & typename base_type<U>::type()
0096 );
0097 };
0098 template<typename T, typename U>
0099 struct bitwise_xor_result {
0100 using type = decltype(
0101 typename base_type<T>::type()
0102 ^ typename base_type<U>::type()
0103 );
0104 };
0105 };
0106
0107 }
0108 }
0109
0110 #endif