Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2007-01-28 07:33:34

Bugs item #1646394, was opened at 2007-01-28 04:33
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: random
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Jens Maurer (jmaurer)
Summary: uniform_int<> with type's maximum availaible range error

Initial Comment:
using boost 1_33_1, MSVC 8.0
using namespace boost;
using namespace std;

typedef int32_t IntType;// the same bug for int8_t int16_t int64_t

uniform_int<IntType> ui(numeric_limits<IntType>::min(), numeric_limits<IntType>::max());
rand48 rng;
variate_generator<rand48, uniform_int<int32_t> > gen(rng, ui);
IntType x = gen(); // infinite loop here
If we makes range smaller or if we using unsigned types - everything is OK
So if we will look to uniform_int.hpp we will see.....
template<class IntType = int>
class uniform_int
  typedef IntType result_type;
  explicit uniform_int(IntType min = 0, IntType max = 9)
    : _min(min), _max(max)
    assert(min <= max); init();
  result_type _min, _max, _range;
  void init()
    _range = _max - _min;// for SIGNED types and maximum available range we will receive..... of course -1 !!!!!! }
......}Also i want to draw the attention russian-speaking boost developers to the


You can respond by visiting:

Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at