[libcxx-commits] [PATCH] D114920: [libc++] Explicitly reject `uniform_int_distribution<bool>`.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 7 14:27:17 PST 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__random/is_valid_inttype.h:21-40
+// [rand.req.genl]/1.5:
+// The effect of instantiating a template that has a template type parameter
+// named IntType is undefined unless the corresponding template argument is
+// cv-unqualified and is one of short, int, long, long long, unsigned short,
+// unsigned int, unsigned long, or unsigned long long.
+
+template<class> struct __random_is_valid_inttype : false_type {};
----------------
ldionne wrote:
> Quuxplusone wrote:
> > I'm not thrilled about this helper or its placement/naming, but it seemed like the best option.
> > Incidentally, this also gives people a sneaky libc++ internal detail that they can (unsupportedly) specialize in order to re-enable the removed functionality for specific user-defined types.
> > Should this helper be named `__libcpp_*`?
> Yeah, let's use `__libcpp_*`. I don't like that name, but I think it's worth doing it if it reduces the likelihood of users messing around with our internal details.
Will rename to `__libcpp_random_is_valid_inttype`.

Also yuck, `libcxx/benchmarks/vector_operations.bench.cpp` uses `uniform_int_distribution<char>` in order to get random example data for its vectors. Maybe we should just support that. It would match libstdc++, too.

`uniform_int_distribution<char/int8_t/uint8_t>`: GCC accepts, MSVC rejects with static_assert.
`uniform_int_distribution<bool>`: GCC and MSVC both reject, with ugly template error message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114920/new/

https://reviews.llvm.org/D114920



More information about the libcxx-commits mailing list