Opened 14 years ago
Closed 13 years ago
#2887 closed Bugs (fixed)
mersenne_twister generated copy ctor overloaded by a template ctor
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | random |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | Copy ctor Bug | Cc: |
Description
Compiled-generated copy constructor and assignment operator are fine, but the copy constructor is overloaded by mersenne_twister(Generator & gen) { seed(gen); } even is the Generator type is mersenne_twister;
template<class Generator> explicit mersenne_twister(Generator & gen) { seed(gen); } // compiler-generated copy ctor and assignment operator are fine
Hence calling
boost::mt19937 rng(0); boost::mt19937 rngcopy(rng); std::cout << (rng==rngcopy) << std::endl;
yields "false".
Maybe a boost::disable_if<boost::is_same<mersenne_twister,Generator> > solves the problem.
See also the workaround made in default constructor of boost::pass_through_engine to avoid matching Generator & constructor
S.
Attachments (1)
Change History (4)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Keywords: | Copy ctor Bug added; boost::random removed |
---|---|
Summary: | boost::mersenne_twister copy constructor → mersenne_twister generated copy ctor overloaded by a template ctor |
Note:
See TracTickets
for help on using tickets.
In mersenne_twister.hpp, replacing
by
and add includes
seems to solve it. No need to handle with the const case.
Then, one has to do it for other generators and, in pass_through_engine.hpp, one can then replace
by
.