Replace last use of std::uniform_int_distribution with our own

Our implementation should be slightly faster, and has the
advantage of being consistent between platforms. This does not
have immediate user impact, because we currently use random_device
to generate random seed for resampling, but if we decide to change
this in the future, it is one less place to fix.
This commit is contained in:
Martin Hořeňovský 2024-04-02 18:13:15 +02:00
parent d99eb8bec8
commit bff6e35e2b
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -12,6 +12,7 @@
#include <catch2/internal/catch_compiler_capabilities.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_floating_point_helpers.hpp> #include <catch2/internal/catch_floating_point_helpers.hpp>
#include <catch2/internal/catch_random_number_generator.hpp> #include <catch2/internal/catch_random_number_generator.hpp>
#include <catch2/internal/catch_uniform_integer_distribution.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -38,7 +39,7 @@ namespace Catch {
double const* last, double const* last,
Estimator& estimator ) { Estimator& estimator ) {
auto n = static_cast<size_t>( last - first ); auto n = static_cast<size_t>( last - first );
std::uniform_int_distribution<size_t> dist( 0, n - 1 ); Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
sample out; sample out;
out.reserve( resamples ); out.reserve( resamples );