Ticket #4179: boost.timeDurationArithmeticOnTickType.diff
File boost.timeDurationArithmeticOnTickType.diff, 4.3 KB (added by , 9 years ago) |
---|
-
boost/date_time/int_adapter.hpp
diff -pru boost-1.41.0.cmake0.orig/boost/date_time/int_adapter.hpp boost-1.41.0.cmake0/boost/date_time/int_adapter.hpp
old new public: 134 134 { 135 135 return (compare(rhs) == 0); 136 136 } 137 bool operator==(const int & rhs) const137 bool operator==(const int_type& rhs) const 138 138 { 139 139 // quiets compiler warnings 140 140 bool is_signed = std::numeric_limits<int_type>::is_signed; … … public: 151 151 { 152 152 return (compare(rhs) != 0); 153 153 } 154 bool operator!=(const int & rhs) const154 bool operator!=(const int_type& rhs) const 155 155 { 156 156 // quiets compiler warnings 157 157 bool is_signed = std::numeric_limits<int_type>::is_signed; … … public: 168 168 { 169 169 return (compare(rhs) == -1); 170 170 } 171 bool operator<(const int & rhs) const171 bool operator<(const int_type& rhs) const 172 172 { 173 173 // quiets compiler warnings 174 174 bool is_signed = std::numeric_limits<int_type>::is_signed; -
boost/date_time/time_duration.hpp
diff -pru boost-1.41.0.cmake0.orig/boost/date_time/time_duration.hpp boost-1.41.0.cmake0/boost/date_time/time_duration.hpp
old new namespace date_time { 164 164 { 165 165 return duration_type(ticks_ + d.ticks_); 166 166 } 167 duration_type operator/( long longdivisor) const167 duration_type operator/(tick_type divisor) const 168 168 { 169 169 return duration_type(ticks_ / divisor); 170 170 } … … namespace date_time { 179 179 return duration_type(ticks_); 180 180 } 181 181 //! Division operations on a duration with an integer. 182 duration_type operator/=( long longdivisor)182 duration_type operator/=(tick_type divisor) 183 183 { 184 184 ticks_ = ticks_ / divisor; 185 185 return duration_type(ticks_); 186 186 } 187 187 //! Multiplication operations an a duration with an integer 188 duration_type operator*( long longrhs) const188 duration_type operator*(tick_type rhs) const 189 189 { 190 190 return duration_type(ticks_ * rhs); 191 191 } 192 duration_type operator*=( long longdivisor)192 duration_type operator*=(tick_type divisor) 193 193 { 194 194 ticks_ = ticks_ * divisor; 195 195 return duration_type(ticks_); -
libs/date_time/test/posix_time/testduration.cpp
diff -pru boost-1.41.0.cmake0.orig/libs/date_time/test/posix_time/testduration.cpp boost-1.41.0.cmake0/libs/date_time/test/posix_time/testduration.cpp
old new main() 61 61 t_5.fractional_seconds() == 5)); 62 62 t_5 = time_duration(3,15,8,0) / 2; 63 63 check("divide int", t_5 == time_duration(1,37,34,0)); 64 t_5 = time_duration(1000000, 0, 0, 0);65 t_5 /= 3600000000LL;66 check("divide equal long long", time_duration(0, 0, 1, 0) == t_5);67 t_5 = time_duration(1000000, 0, 0, 0) / 3600000000LL;68 check("divide long long", time_duration(0, 0, 1, 0) == t_5);69 64 { 70 65 time_duration td = hours(5); 71 66 td *= 5; 72 67 check("mult-equals int", time_duration(25,0,0,0) == td); 73 68 } 74 t_5 = time_duration(0, 0, 1, 0); 75 t_5 *= 3600000000LL; 76 check("multiply equals long long", time_duration(1000000, 0, 0, 0) == t_5); 77 t_5 = time_duration(0, 0, 1, 0) * 3600000000LL; 78 check("multiply long long", time_duration(1000000, 0, 0, 0) == t_5); 69 if (sizeof(time_duration::tick_type) == 8) 70 { 71 std::cout << "testing time_duration 64-bit multiplication and division" << std::endl; 72 t_5 = time_duration(0, 0, 1, 0); 73 t_5 *= 3600000000LL; 74 check("multiply equals long long", time_duration(1000000, 0, 0, 0) == t_5); 75 t_5 = time_duration(0, 0, 1, 0) * 3600000000LL; 76 check("multiply long long", time_duration(1000000, 0, 0, 0) == t_5); 77 t_5 = time_duration(1000000, 0, 0, 0); 78 t_5 /= 3600000000LL; 79 check("divide equal long long", time_duration(0, 0, 1, 0) == t_5); 80 t_5 = time_duration(1000000, 0, 0, 0) / 3600000000LL; 81 check("divide long long", time_duration(0, 0, 1, 0) == t_5); 82 } 79 83 80 84 t_5 = t_2 + t_1; 81 85 //VC6 goes ambiguous on the next line...