Opened 14 years ago
Closed 14 years ago
#2788 closed Patches (invalid)
boost::uniform_01<> template parameter mistake
| Reported by: | Owned by: | Steven Watanabe | |
|---|---|---|---|
| Milestone: | Boost 1.39.0 | Component: | random |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | Cc: |
Description
Hi,
In <boost/random/uniform_01.hpp> (r51337)
line183: template<class UniformRandomNumberGenerator = double, class RealType = double>
UniformRandomNumberGenerator can't use "double" to be default type.
Change History (2)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Yes. That's expected. The code shouldn't have compiled before my changes either.
#include <boost/random.hpp>
int main(void) {
boost::uniform_01<boost::mt19937> rng; // illegal--no default constructor
boost::mt19937 rng;
// ok. Old implementation. Copies rng.
boost::uniform_01<boost::mt19937> dist(rng);
double x = dist();
// ok. Modification of old implementation.
// stores a reference to rng.
boost::uniform_01<boost::mt19937&> dist(rng);
double x = dist();
// ok. new implementation
boost::uniform_01<> dist;
double x = dist(rng);
return 0;
}
Note:
See TracTickets
for help on using tickets.

Hi,
I confuse old "UniformRandomNumberGenerator" and your new "UniformRandomNumberGenerato". I tried in my test code.
#include <boost/random.hpp>
int main(void) {
}
It's can't compile success.