absl/random: Convert absl::BitGen / absl::InsecureBitGen to classes from aliases.

PiperOrigin-RevId: 733063284
Change-Id: If0af60b24bcc59b6fe3a6882aebd427b8b10f3a0
diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel
index ef8ac7e..cc95d9c 100644
--- a/absl/random/BUILD.bazel
+++ b/absl/random/BUILD.bazel
@@ -42,9 +42,9 @@
     deps = [
         ":distributions",
         ":seed_sequences",
+        "//absl/base:config",
         "//absl/random/internal:nonsecure_base",
         "//absl/random/internal:pcg_engine",
-        "//absl/random/internal:pool_urbg",
         "//absl/random/internal:randen_engine",
     ],
 )
diff --git a/absl/random/CMakeLists.txt b/absl/random/CMakeLists.txt
index 8f62696..9cd301d 100644
--- a/absl/random/CMakeLists.txt
+++ b/absl/random/CMakeLists.txt
@@ -24,10 +24,10 @@
   LINKOPTS
     ${ABSL_DEFAULT_LINKOPTS}
   DEPS
+    absl::config
     absl::random_distributions
     absl::random_internal_nonsecure_base
     absl::random_internal_pcg_engine
-    absl::random_internal_pool_urbg
     absl::random_internal_randen_engine
     absl::random_seed_sequences
 )
diff --git a/absl/random/random.h b/absl/random/random.h
index c955be6..b55b361 100644
--- a/absl/random/random.h
+++ b/absl/random/random.h
@@ -34,10 +34,10 @@
 #include <cstdint>
 #include <random>
 
+#include "absl/base/config.h"
 #include "absl/random/distributions.h"  // IWYU pragma: export
-#include "absl/random/internal/nonsecure_base.h"  // IWYU pragma: export
-#include "absl/random/internal/pcg_engine.h"  // IWYU pragma: export
-#include "absl/random/internal/pool_urbg.h"
+#include "absl/random/internal/nonsecure_base.h"
+#include "absl/random/internal/pcg_engine.h"
 #include "absl/random/internal/randen_engine.h"
 #include "absl/random/seed_sequences.h"  // IWYU pragma: export
 
@@ -95,31 +95,46 @@
 // types on modern x86, ARM, and PPC architectures.
 //
 // This type is thread-compatible, but not thread-safe.
+class BitGen : private random_internal::NonsecureURBGBase<
+                   random_internal::randen_engine<uint64_t>> {
+  using Base = random_internal::NonsecureURBGBase<
+      random_internal::randen_engine<uint64_t>>;
 
-// ---------------------------------------------------------------------------
-// absl::BitGen member functions
-// ---------------------------------------------------------------------------
+ public:
+  using result_type = typename Base::result_type;
 
-// absl::BitGen::operator()()
-//
-// Calls the BitGen, returning a generated value.
+  // BitGen()
+  // BitGen(SeedSequence seed_seq)
+  //
+  // Copy disallowed.
+  // Move allowed.
+  using Base::Base;
+  using Base::operator=;
 
-// absl::BitGen::min()
-//
-// Returns the smallest possible value from this bit generator.
+  // BitGen::min()
+  //
+  // Returns the smallest possible value from this bit generator.
+  using Base::min;
 
-// absl::BitGen::max()
-//
-// Returns the largest possible value from this bit generator.
+  // BitGen::max()
+  //
+  // Returns the largest possible value from this bit generator.
+  using Base::max;
 
-// absl::BitGen::discard(num)
-//
-// Advances the internal state of this bit generator by `num` times, and
-// discards the intermediate results.
-// ---------------------------------------------------------------------------
+  // BitGen::discard(num)
+  //
+  // Advances the internal state of this bit generator by `num` times, and
+  // discards the intermediate results.
+  using Base::discard;
 
-using BitGen = random_internal::NonsecureURBGBase<
-    random_internal::randen_engine<uint64_t>>;
+  // BitGen::operator()()
+  //
+  // Invoke the URBG, returning a generated value.
+  using Base::operator();
+
+  using Base::operator==;
+  using Base::operator!=;
+};
 
 // -----------------------------------------------------------------------------
 // absl::InsecureBitGen
@@ -157,32 +172,51 @@
 // `absl::InsecureBitGen` is not cryptographically secure.
 //
 // Prefer `absl::BitGen` over `absl::InsecureBitGen` as the general type is
-// often fast enough for the vast majority of applications.
-
-using InsecureBitGen =
-    random_internal::NonsecureURBGBase<random_internal::pcg64_2018_engine>;
-
-// ---------------------------------------------------------------------------
-// absl::InsecureBitGen member functions
-// ---------------------------------------------------------------------------
-
-// absl::InsecureBitGen::operator()()
+// often fast enough for the vast majority of applications. However, it is
+// reasonable to use `absl::InsecureBitGen` in tests or when using a URBG
+// in small isolated tasks such as in `std::shuffle`.
 //
-// Calls the InsecureBitGen, returning a generated value.
+// This type is thread-compatible, but not thread-safe.
+class InsecureBitGen : private random_internal::NonsecureURBGBase<
+                           random_internal::pcg64_2018_engine> {
+  using Base =
+      random_internal::NonsecureURBGBase<random_internal::pcg64_2018_engine>;
 
-// absl::InsecureBitGen::min()
-//
-// Returns the smallest possible value from this bit generator.
+ public:
+  using result_type = typename Base::result_type;
 
-// absl::InsecureBitGen::max()
-//
-// Returns the largest possible value from this bit generator.
+  // InsecureBitGen()
+  // InsecureBitGen(SeedSequence seed_seq)
+  //
+  // Copy disallowed.
+  // Move allowed.
+  using Base::Base;
+  using Base::operator=;
 
-// absl::InsecureBitGen::discard(num)
-//
-// Advances the internal state of this bit generator by `num` times, and
-// discards the intermediate results.
-// ---------------------------------------------------------------------------
+  // InsecureBitGen::min()
+  //
+  // Returns the smallest possible value from this bit generator.
+  using Base::min;
+
+  // InsecureBitGen::max()
+  //
+  // Returns the largest possible value from this bit generator.
+  using Base::max;
+
+  // InsecureBitGen::discard(num)
+  //
+  // Advances the internal state of this bit generator by `num` times, and
+  // discards the intermediate results.
+  using Base::discard;
+
+  // InsecureBitGen::operator()()
+  //
+  // Invoke the URBG, returning a generated value.
+  using Base::operator();
+
+  using Base::operator==;
+  using Base::operator!=;
+};
 
 ABSL_NAMESPACE_END
 }  // namespace absl