Boost logo

Boost Users :

Subject: Re: [Boost-users] [random] Singleton engine
From: Diederick C. Niehorster (dcnieho_at_[hidden])
Date: 2009-07-26 01:54:57


Dear Robert,
Thanks! I will look into
http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/singleton.html,
I should not be reinventing the wheel ;)

Dear Steven,
Sharp eye, good point. Now two different numbers get generated and all
those destructor calls dissapeared.

It seems one too many dissapeared even (see program output below).
Even though MSVC does not complain about memory leaks, at end of
program the destructor never gets called. Lets see if Robert's
singleton class solves this, otherwise i suppose i should look into
using scoped_ptr?

Thanks a lot for your replies,
Diederick

------ output:
check 0
00000000
ctor 1
after ctor 1
003462E0
random: 8148
dtor 1
ctor 2
after ctor 2
003462E0
random: 1355
Press any key to continue . . .

On Sun, Jul 26, 2009 at 1:16 PM, Steven Watanabe<watanabesj_at_[hidden]> wrote:
> AMDG
>
> Diederick C. Niehorster wrote:
>>
>> template<class Dist>
>> class CRandom
>> {
>> public:
>> <snip>
>> private:
>>    boost::variate_generator<boost::mt19937,Dist> Gen;
>> };
>
> This copies the engine.  Try
> boost::variate_generator<boost::mt19937&,Dist>
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net