Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/mesh/shim/repeater/HostArduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <stdlib.h>
#include <string.h>

#include <type_traits>

// Seeded rather than entropic: a run has to be reproducible from its seed, and
// the identity a node generates comes through here.
inline void randomSeed(unsigned long seed) { srandom(seed); }
Expand All @@ -21,15 +23,15 @@ inline void randomSeed(unsigned long seed) { srandom(seed); }
// like a macro call with one argument. That produced 368 errors inside libstdc++
// and none in any MeshCore file, which is a confusing place to start debugging.
template <class T, class U>
constexpr auto min(T a, U b) -> decltype(a < b ? a : b) {
constexpr auto min(T a, U b) -> std::decay_t<decltype(a < b ? a : b)> {
return a < b ? a : b;
}
template <class T, class U>
constexpr auto max(T a, U b) -> decltype(a > b ? a : b) {
constexpr auto max(T a, U b) -> std::decay_t<decltype(a > b ? a : b)> {
return a > b ? a : b;
}
template <class T, class L, class H>
constexpr auto constrain(T v, L lo, H hi) -> decltype(v < lo ? lo : (v > hi ? hi : v)) {
constexpr auto constrain(T v, L lo, H hi) -> std::decay_t<decltype(v < lo ? lo : (v > hi ? hi : v))> {
return v < lo ? lo : (v > hi ? hi : v);
}

Expand Down