News for hackers. Stuff that matters.
Re:Show HN: Fast Random Library for C++17 by spacechild1 on Monday June 02, 2025 @11:44AM (#44160033)
This looks nice! One thing I find particularly noteworthy:

- Faster uniform / normal distributions that produce same sequences on every platform

This is very useful if you want to reliably repeat simulations across platforms!

One question:

    template<class T>
    constexpr T& rand_choice(std::initializer_list<T> objects) noexcept;

Isn't this returning a reference to a local variable? In my understanding, 'objects' is destroyed when rand_choice() returns.
Re:Show HN: Fast Random Library for C++17 by GeorgeHaldane on Monday June 02, 2025 @12:35PM (#44160559)
Thanks, that is indeed the case when list doesn't consist of literals, fixed in the new commit.