123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #ifndef BOOST_SAFE_NUMERICS_NATIVE_HPP
- #define BOOST_SAFE_NUMERICS_NATIVE_HPP
- #include <type_traits>
- #include <limits>
- namespace boost {
- namespace safe_numerics {
- struct native {
- public:
-
- template<typename T, typename U>
- struct addition_result {
- using type = decltype(
- typename base_type<T>::type()
- + typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct subtraction_result {
- using type = decltype(
- typename base_type<T>::type()
- - typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct multiplication_result {
- using type = decltype(
- typename base_type<T>::type()
- * typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct division_result {
- using type = decltype(
- typename base_type<T>::type()
- / typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct modulus_result {
- using type = decltype(
- typename base_type<T>::type()
- % typename base_type<U>::type()
- );
- };
-
-
-
- template<typename T, typename U>
- struct comparison_result {
- using type = decltype(
- typename base_type<T>::type()
- + typename base_type<U>::type()
- );
- };
-
- template<typename T, typename U>
- struct left_shift_result {
- using type = decltype(
- typename base_type<T>::type()
- << typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct right_shift_result {
- using type = decltype(
- typename base_type<T>::type()
- >> typename base_type<U>::type()
- );
- };
-
- template<typename T, typename U>
- struct bitwise_or_result {
- using type = decltype(
- typename base_type<T>::type()
- | typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct bitwise_and_result {
- using type = decltype(
- typename base_type<T>::type()
- & typename base_type<U>::type()
- );
- };
- template<typename T, typename U>
- struct bitwise_xor_result {
- using type = decltype(
- typename base_type<T>::type()
- ^ typename base_type<U>::type()
- );
- };
- };
- }
- }
- #endif
|