diff --git a/src/hal/circular_buffer.h b/src/hal/circular_buffer.h index 7e8249a..4330e15 100644 --- a/src/hal/circular_buffer.h +++ b/src/hal/circular_buffer.h @@ -1,10 +1,6 @@ #pragma once - -#include #include -#ifndef __AVR__ -#include -#endif +#include "../limits.h" /// A generic circular index class which can be used to build circular buffers /// Can hold up to size elements @@ -15,10 +11,8 @@ template class CircularIndex { public: -#ifndef __AVR__ static_assert(size <= std::numeric_limits::max() / 2, "index_t is too small for the requested size"); -#endif constexpr inline CircularIndex() : tail(0) diff --git a/src/limits.h b/src/limits.h new file mode 100644 index 0000000..232f03b --- /dev/null +++ b/src/limits.h @@ -0,0 +1,23 @@ +#pragma once +#ifndef __AVR__ +#include +#else + +// A minimal std::numeric_limits for platforms that lack one +#include +#include + +namespace std { + +template +class numeric_limits; + +template <> +class numeric_limits { +public: + static constexpr size_t max() { return UINT8_MAX; } +}; + +} // namespace std + +#endif