Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2023-11-30 19:29:04


Niall Douglas wrote:
> > I don't understand your objections, sorry.
> >
> > Are you saying that the generators in <random> don't offer the ability
> > to copy, serialize, deserialize and give identical output? Because they do.
>
> They do within the same execution of a program, but not across
> executions, or across standard libraries, or across architectures. Given
> its simplicity, I have never understood how a linear congruential
> engine's state couldn't have been given that added guarantee.

Not sure what you're talking about, sorry. All that is guaranteed.

E.g. https://godbolt.org/z/a17oboMMq

#include <random>
#include <sstream>
#include <iostream>

int main()
{
    std::mt19937 e1( 5 );

    std::stringstream ss;

    ss << e1;

    std::mt19937 e2;

    ss >> e2;

    std::cout << e1() << std::endl;
    std::cout << e2() << std::endl;
}

The output of this program is fully specified by the standard.

> I came badly unstuck with mt19937 one time. On one architecture it was
> 20x slower AND produced completely different output for a specific seed.

Not much WG21 can do about that. It's just a buggy implementation.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk