diff --git a/platform/mbed_chrono.h b/platform/mbed_chrono.h index a051588c71..210d64b3fe 100644 --- a/platform/mbed_chrono.h +++ b/platform/mbed_chrono.h @@ -19,6 +19,7 @@ #ifndef __MBED_CHRONO_H__ #define __MBED_CHRONO_H__ +#include "mbed_toolchain.h" #include #include #include @@ -85,10 +86,7 @@ inline namespace chrono_literals { constexpr chrono::deciseconds operator "" _ds(unsigned long long x) { chrono::deciseconds::rep val = static_cast(x); - if (val < 0) { - assert(false); - } - assert(static_cast(val) == x); + assert(val >= 0 && static_cast(val) == x); return chrono::deciseconds(val); } @@ -106,10 +104,7 @@ constexpr chrono::deciseconds operator "" _ds(unsigned long long x) constexpr chrono::centiseconds operator "" _cs(unsigned long long x) { chrono::centiseconds::rep val = static_cast(x); - if (val < 0) { - assert(false); - } - assert(static_cast(val) == x); + assert(val >= 0 && static_cast(val) == x); return chrono::centiseconds(val); }