Ticket #5399: random_seed_impl_exceptions.patch

File random_seed_impl_exceptions.patch, 2.0 KB (added by gromer@…, 10 years ago)

New patch as of 1.49.0

  • boost/random/detail/seed_impl.hpp

    old new  
    1515
    1616#include <stdexcept>
    1717#include <boost/cstdint.hpp>
     18#include <boost/throw_exception.hpp>
    1819#include <boost/config/no_tr1/cmath.hpp>
    1920#include <boost/integer/integer_mask.hpp>
    2021#include <boost/integer/static_log2.hpp>
     
    253254    IntType s = 0;
    254255    for(int j = 0; j < k; ++j) {
    255256        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."));
    257258        }
    258259        IntType digit = const_mod<IntType, m>::apply(IntType(*first++));
    259260        IntType mult = IntType(1) << 32*j;
     
    303304        UIntType val = 0;
    304305        for(std::size_t k = 0; k < (w+31)/32; ++k) {
    305306            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."));
    307308            }
    308309            val += static_cast<UIntType>(*first++) << 32*k;
    309310        }
     
    373374        RealType val = RealType(0);
    374375        RealType mult = divisor;
    375376        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."));
    377378            val += *first * mult;
    378379            mult *= two32;
    379380        }
    380381        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."));
    382383            val += (*first & mask) * mult;
    383384            ++first;
    384385        }