[libcxx-commits] [PATCH] D126823: [libc++] Support char and unsigned char in integer distributions as an extension
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 1 13:29:17 PDT 2022
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
In D125283 <https://reviews.llvm.org/D125283>, we ensured that integer distributions would not compile when
used with arbitrary unsupported types. This effectively enforced what
the Standard mentions here: http://eel.is/c++draft/rand#req.genl-1.5.
However, this also had the effect of breaking some users that were
using integer distributions with unsupported types like int8_t. Since we
already support using __int128_t in those distributions, it is reasonable
to also support smaller types like int8_t and its unsigned variant. This
commit implements that, adds tests and documents the extension. Note that
we voluntarily don't add support for instantiating these distributions
with bool and char, since those are not integer types. However, it is
trivial to replace uses of these random distributions on char using int8_t.
It is also interesting to note that in the process of adding tests
for smaller types, I discovered that our distributions sometimes don't
provide as faithful a distribution when instantiated with smaller types,
so I had to relax a couple of tests.
Supersedes D125283 <https://reviews.llvm.org/D125283>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126823
Files:
libcxx/docs/ReleaseNotes.rst
libcxx/docs/UsingLibcxx.rst
libcxx/include/__random/binomial_distribution.h
libcxx/include/__random/discrete_distribution.h
libcxx/include/__random/geometric_distribution.h
libcxx/include/__random/is_valid.h
libcxx/include/__random/negative_binomial_distribution.h
libcxx/include/__random/poisson_distribution.h
libcxx/include/__random/uniform_int_distribution.h
libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
libcxx/test/std/numerics/rand/rand.dist/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126823.433526.patch
Type: text/x-patch
Size: 47227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220601/9bf5fb79/attachment-0001.bin>
More information about the libcxx-commits
mailing list