samedi 28 octobre 2023

Is std::uniform_int_distribution

According to the cppreference documentation on std::uniform_int_distribution,

The effect is undefined if [IntType] is not one of: short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long.

I'm not sure of how this applies to std::size_t - namely with these 3 confusions:

  1. On one hand, std::size_t, as far as I know, is usually a typedef of one of the unsigned types in that list.
  2. However, I'm not sure if the standard mandates that always be the case.
  3. I'm not sure if "undefined if [IntType] is not one of: ..." implies IntType has to nominally match something from that list (the type has to explicitly be one of those, by name) or whether it can structurally match (so a typedef to one of those is considered acceptable as well).

Is std::uniform_int_distribution<std::size_t> undefined behavior?

Aucun commentaire:

Enregistrer un commentaire