diff --git a/scripts/DallasFuncs.h b/scripts/DallasFuncs.h index ab5e504c..50bfbe69 100644 --- a/scripts/DallasFuncs.h +++ b/scripts/DallasFuncs.h @@ -18,14 +18,17 @@ class user_var : public std::variant { self = static_cast(v); } template void set_type() noexcept { static_cast(*this) = T{}; } - void operator++(int) noexcept { std::visit([](auto &&uv) { ++uv; }, *this); } - void operator--(int) noexcept { std::visit([](auto &&uv) { ++uv; }, *this); } - template void operator+=(T &&r) noexcept { std::visit([&](auto &&uv) { uv += std::forward(r); }, *this); } - template void operator-=(T &&r) noexcept { std::visit([&](auto &&uv) { uv -= std::forward(r); }, *this); } - template bool operator==(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv == std::forward(r); }, *this); } - template bool operator!=(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv != std::forward(r); }, *this); } - template bool operator<(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv < std::forward(r); }, *this); } - template bool operator>(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv > std::forward(r); }, *this); } + + // The explicit cast to base type is for the sake of older compilers + // like GCC 9 which is missing a deduction guide or so (cf. P2162R2). + void operator++(int) noexcept { std::visit([](auto &&uv) { ++uv; }, static_cast(*this)); } + void operator--(int) noexcept { std::visit([](auto &&uv) { ++uv; }, static_cast(*this)); } + template void operator+=(T &&r) noexcept { std::visit([&](auto &&uv) { uv += std::forward(r); }, static_cast(*this)); } + template void operator-=(T &&r) noexcept { std::visit([&](auto &&uv) { uv -= std::forward(r); }, static_cast(*this)); } + template bool operator==(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv == std::forward(r); }, static_cast(*this)); } + template bool operator!=(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv != std::forward(r); }, static_cast(*this)); } + template bool operator<(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv < std::forward(r); }, static_cast(*this)); } + template bool operator>(T &&r) noexcept { return std::visit([&](auto &&uv) { return uv > std::forward(r); }, static_cast(*this)); } }; #define MAX_USER_VARS 25 // make sure this value matches the USERTYPE definition