Skip to content

Commit

Permalink
Use constexpr.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhuggett committed Sep 27, 2024
1 parent 59d373a commit cbd804d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/pstore/support/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ namespace pstore {
random_generator ()
: generator_ (device_ ()) {}

Ty get (Ty max) { return distribution_ (generator_) % max; }
Ty get () {
auto const max = std::numeric_limits<Ty>::max ();
static_assert (max > Ty (0), "max must be > 0");
constexpr Ty get (Ty max) { return distribution_ (generator_) % max; }
constexpr Ty get () {
constexpr auto max = std::numeric_limits<Ty>::max ();
static_assert (max > Ty{0}, "max must be > 0");
return get (max);
}

Expand Down

0 comments on commit cbd804d

Please sign in to comment.