Opened 15 years ago

Closed 14 years ago

#1544 closed Bugs (fixed)

uniform_01 w/ref template param causes ref to ref error

Reported by: Neal Becker <ndbecker2@…> Owned by: No-Maintainer
Milestone: Boost 1.36.0 Component: random
Version: Boost 1.34.1 Severity: Problem
Keywords: Cc:

Description

From uniform_01 doc: WARNING: As an exception / historic accident, this class takes a UniformRandomNumberGenerator as its constructor parameter, and BY VALUE. Usually, you want reference semantics so that the state of the passed-in generator is changed in-place and not copied. In that case, explicitly supply a reference type for the template parameter UniformRandomNumberGenerator.

OK, but what about: from uniform_01.hpp:

base_type& base() { return _rng; }

So, for example: #include <boost/random.hpp>

typedef boost::mt19937 rng_t; struct F {

F (rng_t & r) :

gen (r){}

double operator()() { return gen(); }

boost::uniform_01<rng_t&> gen;

};

/usr/local/src/boost.hg/boost/random/uniform_01.hpp:53: error: forming reference to reference type ‘rng_t&’

Change History (2)

comment:1 by Marshall Clow, 15 years ago

Owner: set to No-Maintainer

comment:2 by Steven Watanabe, 14 years ago

Resolution: fixed
Status: newclosed

(In [51337]) Convert uniform_01 to the current distribution interface, dispatching on the first template paramter to retain backwards compatibility. Fixes #599. Fixes #1544. Fixes #2679

Note: See TracTickets for help on using tickets.