From 2281a57bc9a8ef2cc82ece8d3e8d242b57a7d2f4 Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 2 Nov 2021 23:27:06 +0000 Subject: [PATCH] Hack to get arround the retarded name-based hiding in derrived class overrides fucking up name base name lookups. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fuck sepples, seriously Fortune for cpprng's current commit: Blessing − 吉 --- include/rng.h | 3 +++ include/rng/crand.h | 12 ++++++------ src/main.cpp | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/rng.h b/include/rng.h index 1df12e8..5afcfaf 100644 --- a/include/rng.h +++ b/include/rng.h @@ -11,6 +11,9 @@ #define CTOR_COPY(name) name(const name& copy) #define CTOR_MOVE(name) name(name&& move) +// ugly hack to get around the absolutely retarded name lookup restrictions when overriding +#define RNG_OVERRIDE(ty, nm, rest) using Random::nm; ty nm rest override + namespace _rng__util { struct divp { diff --git a/include/rng/crand.h b/include/rng/crand.h index c104fd8..6caf385 100644 --- a/include/rng/crand.h +++ b/include/rng/crand.h @@ -17,14 +17,14 @@ namespace rng crand(u64 seed); inline ~crand() override{} + + RNG_OVERRIDE(inline i64, next_i64, ()) { return _sample_int(); } + RNG_OVERRIDE(u64, next_u64,()); - inline i64 next_i64() override { return _sample_int(); } - u64 next_u64() override; + RNG_OVERRIDE(i32, next_i32,()); + RNG_OVERRIDE(u32, next_u32,()); - i32 next_i32() override; - u32 next_u32() override; - - void next_bytes(u8* p, usize n) override; + RNG_OVERRIDE(void, next_bytes, (u8* p, usize n)); protected: inline constexpr i64 _max_i64() const override { return RANGE_MAX; } inline constexpr u64 _max_u64() const override { return (u64)RANGE_MAX; } diff --git a/src/main.cpp b/src/main.cpp index af9f001..f90a0e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,8 +17,7 @@ void r(Random& r) void rng_test() { - crand _r(123); - Random& r = _r; + crand r(123); printf("%lu %lu %lu\n", r.next_u64(), r.next_u64(), r.next_u64()); printf("%d %d %d\n", r.next_i32(), r.next_i32(), r.next_i32()); printf("%u %u %u\n", r.next_u32(), r.next_u32(), r.next_u32());