Closed shohirose closed 10 months ago
A quick fix is to use uniform_int_distribution<int>
and cast to char
or char_32_t
:
char random_ascii()
{
static std::uniform_int_distribution<int> dist(0x00, 0x7F);
return static_cast<char>(dist(engine));
}
char32_t random_unicode()
{
static std::uniform_int_distribution<int> dist(0x80, 0x10'FFFF);
return static_cast<char32_t>(dist(engine));
}
But I am not sure if casting from int to char or char32_t is okay or not.
Can you make a PR that uses std::uint_least32_t
for the random_unicode()
case?
MSVC 2022 17.7.5 fails to compile due to the following static assertion failures:
These are caused by the use of
uniformt_int_distribution<char>
anduniformt_int_distribution<char32_t>
in thebenchmarks/swar/main.cpp
.