From 08a26544a981bbf16375b84b62509285d35d488e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 10 Jun 2021 14:41:35 +0200 Subject: ringbuffer: Move the 'T nullelem' to ctor, simplifying ringbuffer declaration Having the `nullelem` passed as reference as a template parameter gives user the burden to have a static instance setup before declaration. This is not nice. For now, we better pass `nullelem` via the constructor. We would like to pass `T nullelem` as a non-type template parameter of type `T`, a potential Class. However, this is only allowed in C++20 and we use C++17 for now. --- test/test_lfringbuffer11.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/test_lfringbuffer11.cpp') diff --git a/test/test_lfringbuffer11.cpp b/test/test_lfringbuffer11.cpp index eddb86d..03317a1 100644 --- a/test/test_lfringbuffer11.cpp +++ b/test/test_lfringbuffer11.cpp @@ -40,7 +40,7 @@ using namespace jau; typedef uint8_t IntegralType; typedef uint8_t TrivialType; static const TrivialType TrivialTypeNullElem(0xff); -typedef ringbuffer TrivialTypeRingbuffer; +typedef ringbuffer TrivialTypeRingbuffer; constexpr static const IntegralType integral_modulus = 254; @@ -49,12 +49,12 @@ class TestRingbuffer11 { private: TrivialTypeRingbuffer createEmpty(jau::nsize_t initialCapacity) { - TrivialTypeRingbuffer rb(initialCapacity); + TrivialTypeRingbuffer rb(TrivialTypeNullElem, initialCapacity); REQUIRE_MSG("empty "+rb.toString(), rb.isEmpty()); return rb; } TrivialTypeRingbuffer createFull(const std::vector & source) { - TrivialTypeRingbuffer rb(source); + TrivialTypeRingbuffer rb(TrivialTypeNullElem, source); REQUIRE_MSG("full "+rb.toString(), rb.isFull()); return rb; } -- cgit v1.2.3