Ticket #5399: random_seed_impl_exceptions.patch
File random_seed_impl_exceptions.patch, 2.0 KB (added by , 10 years ago) |
---|
-
boost/random/detail/seed_impl.hpp
old new 15 15 16 16 #include <stdexcept> 17 17 #include <boost/cstdint.hpp> 18 #include <boost/throw_exception.hpp> 18 19 #include <boost/config/no_tr1/cmath.hpp> 19 20 #include <boost/integer/integer_mask.hpp> 20 21 #include <boost/integer/static_log2.hpp> … … 253 254 IntType s = 0; 254 255 for(int j = 0; j < k; ++j) { 255 256 if(first == last) { 256 throw ::std::invalid_argument("Not enough elements in call to seed.");257 boost::throw_exception(::std::invalid_argument("Not enough elements in call to seed.")); 257 258 } 258 259 IntType digit = const_mod<IntType, m>::apply(IntType(*first++)); 259 260 IntType mult = IntType(1) << 32*j; … … 303 304 UIntType val = 0; 304 305 for(std::size_t k = 0; k < (w+31)/32; ++k) { 305 306 if(first == last) { 306 throw std::invalid_argument("Not enough elements in call to seed.");307 boost::throw_exception(std::invalid_argument("Not enough elements in call to seed.")); 307 308 } 308 309 val += static_cast<UIntType>(*first++) << 32*k; 309 310 } … … 373 374 RealType val = RealType(0); 374 375 RealType mult = divisor; 375 376 for(int k = 0; k < w/32; ++k, ++first) { 376 if(first == last) throw std::invalid_argument("Not enough elements in call to seed.");377 if(first == last) boost::throw_exception(std::invalid_argument("Not enough elements in call to seed.")); 377 378 val += *first * mult; 378 379 mult *= two32; 379 380 } 380 381 if(mask != 0) { 381 if(first == last) throw std::invalid_argument("Not enough elements in call to seed.");382 if(first == last) boost::throw_exception(std::invalid_argument("Not enough elements in call to seed.")); 382 383 val += (*first & mask) * mult; 383 384 ++first; 384 385 }