Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2887: boost::mersenne_twister copy constructor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-03-26 15:34:56
#2887: boost::mersenne_twister copy constructor
-------------------------------+--------------------------------------------
Reporter: corlay_at_[hidden] | Owner: no-maintainer
Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: random
Version: Boost 1.38.0 | Severity: Problem
Resolution: | Keywords: boost::random
-------------------------------+--------------------------------------------
Comment(by corlay_at_[hidden]):
In mersenne_twister.hpp, replacing
{{{
template<class Generator>
explicit mersenne_twister(Generator & gen) { seed(gen); }
}}}
by
{{{
template<class Generator>
explicit mersenne_twister(Generator & gen, typename disable_if<
is_same<Generator,mersenne_twister>,int >::type = 0) { seed(gen); }
}}}
and add includes
{{{
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
}}}
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
{{{
explicit pass_through_engine(UniformRandomNumberGenerator rng)
// make argument an rvalue to avoid matching Generator& constructor
: _rng(static_cast<typename helper_type::rvalue_type>(rng))
{ }
}}}
by
{{{
explicit pass_through_engine(UniformRandomNumberGenerator rng) :
_rng(rng)
{ }
}}}
.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2887#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC