Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<random>: Cannot save/restore a ranlux48 object in a stream #437

Closed
BillyONeal opened this issue Jan 22, 2020 · 1 comment · Fixed by #2088
Closed

<random>: Cannot save/restore a ranlux48 object in a stream #437

BillyONeal opened this issue Jan 22, 2020 · 1 comment · Fixed by #2088
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@BillyONeal
Copy link
Member

Describe the bug
It appears that the textual representation of ranlux48 is incorrect

Command-line test case
STL version (git commit or Visual Studio version): Visual Studio 2019 version 16.4 (but goes back effectively forever)

C:\Users\bion\Desktop>type test.cpp
#include <iostream>
#include <random>
#include <sstream>

template <typename RND> void check(const char *name) {
  RND g1, g2;
  std::cout << std::boolalpha << name << ": " << (g1 == g2);
  std::stringstream s;
  s << g1;
  s >> g1;
  std::cout << " " << (g1 == g2) << std::endl;
}

int main() {
  check<std::ranlux48>("ranlux48");
  check<std::ranlux24>("ranlux24");
  check<std::mt19937>("mt19937");
}

C:\Users\bion\Desktop>cl /EHsc /W4 /WX /std:c++latest /nologo .\test.cpp
test.cpp

C:\Users\bion\Desktop>.\test.exe
ranlux48: true false
ranlux24: true true
mt19937: true true

C:\Users\bion\Desktop>

Expected behavior
ranlux48: true true
ranlux24: true true
mt19937: true true

This issue is a dual of Microsoft-internal VSO-104809 and DevCom-249085

@BillyONeal BillyONeal added the bug Something isn't working label Jan 22, 2020
@StephanTLavavej StephanTLavavej changed the title <random>: Cannot save/restore a std::ranlux48 object in a stream <random>: Cannot save/restore a ranlux48 object in a stream Jan 23, 2020
@StephanTLavavej
Copy link
Member

I believe this should be resolved as a duplicate of #442. Observe:

using ranlux48_base = subtract_with_carry_engine<unsigned long long, 48, 5, 12>;

using ranlux48 = discard_block_engine<ranlux48_base, 389, 11>;

@StephanTLavavej StephanTLavavej added the duplicate This issue or pull request already exists label Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants