From bc25c526838e8bf8a0ac3cb116b4691745dfcb17 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 29 Jul 2019 22:49:02 -0400 Subject: [PATCH] Although duplicative, resolves function redefinition. --- ClockReceiver/ClockReceiver.hpp | 54 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/ClockReceiver/ClockReceiver.hpp b/ClockReceiver/ClockReceiver.hpp index 1a77a8e72..4ca56dd70 100644 --- a/ClockReceiver/ClockReceiver.hpp +++ b/ClockReceiver/ClockReceiver.hpp @@ -48,16 +48,6 @@ */ -namespace { - -template Target flush(int &value) { - const Target result = Source(value); - value = 0; - return result; -} - -} - /*! Provides a class that wraps a plain int, providing most of the basic arithmetic and Boolean operators, but forcing callers and receivers to be explicit as to usage. @@ -155,14 +145,6 @@ template class WrappedInt { return result; } - /*! - Flushes the value in @c this. The current value is returned, and the internal value - is reset to zero. - */ - template forceinline Target flush() { - return ::flush(length_); - } - // operator int() is deliberately not provided, to avoid accidental subtitution of // classes that use this template. @@ -176,6 +158,16 @@ class Cycles: public WrappedInt { forceinline constexpr Cycles(int l) noexcept : WrappedInt(l) {} forceinline constexpr Cycles() noexcept : WrappedInt() {} forceinline constexpr Cycles(const Cycles &cycles) noexcept : WrappedInt(cycles.length_) {} + + /*! + Flushes the value in @c this. The current value is returned, and the internal value + is reset to zero. + */ + template T flush() { + const T result(*this); + length_ = 0; + return result; + } }; /// Describes an integer number of half cycles: single clock signal transitions. @@ -192,6 +184,22 @@ class HalfCycles: public WrappedInt { return Cycles(length_ >> 1); } + /*! + Flushes the value in @c this. The current value is returned, and the internal value + is reset to zero. + */ + template T flush() { + const T result(*this); + length_ = 0; + return result; + } + + template <> Cycles flush() { + const Cycles result(length_ >> 1); + length_ &= 1; + return result; + } + /*! Severs from @c this the effect of dividing by @c divisor; @c this will end up with the value of @c this modulo @c divisor and @c divided by @c divisor is returned. @@ -204,16 +212,6 @@ class HalfCycles: public WrappedInt { } }; -namespace { - -template <> Cycles flush(int &value) { - const Cycles result(value >> 1); - value &= 1; - return result; -} - -} - // Create a specialisation of WrappedInt::flush for converting HalfCycles to Cycles // without losing the fractional part.