From 17a4e8d934df29ca90451b7e06bee5c178f489f5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 13 May 2024 09:06:35 +0100 Subject: [PATCH] Added ETL_NODISCARD, ETL_CONSTEXPR14 and ETL_NOEXCEPT --- include/etl/absolute.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/include/etl/absolute.h b/include/etl/absolute.h index 5812f86b..7bc5ea66 100644 --- a/include/etl/absolute.h +++ b/include/etl/absolute.h @@ -40,8 +40,10 @@ namespace etl // For signed types. //*************************************************************************** template - ETL_CONSTEXPR typename etl::enable_if::value, T>::type - absolute(T value) + ETL_NODISCARD + ETL_CONSTEXPR + typename etl::enable_if::value, T>::type + absolute(T value) ETL_NOEXCEPT { return (value < T(0)) ? -value : value; } @@ -50,8 +52,10 @@ namespace etl // For unsigned types. //*************************************************************************** template - ETL_CONSTEXPR typename etl::enable_if::value, T>::type - absolute(T value) + ETL_NODISCARD + ETL_CONSTEXPR + typename etl::enable_if::value, T>::type + absolute(T value) ETL_NOEXCEPT { return value; } @@ -65,8 +69,10 @@ namespace etl #else template #endif - ETL_CONSTEXPR typename etl::enable_if::value, TReturn>::type - absolute_unsigned(T value) + ETL_NODISCARD + ETL_CONSTEXPR + typename etl::enable_if::value, TReturn>::type + absolute_unsigned(T value) ETL_NOEXCEPT { return (value == etl::integral_limits::min) ? (etl::integral_limits::max / 2U) + 1U : (value < T(0)) ? TReturn(-value) : TReturn(value); @@ -77,8 +83,10 @@ namespace etl // Returns the result as the unsigned type. //*************************************************************************** template - ETL_CONSTEXPR typename etl::enable_if::value, T>::type - absolute_unsigned(T value) + ETL_NODISCARD + ETL_CONSTEXPR + typename etl::enable_if::value, T>::type + absolute_unsigned(T value) ETL_NOEXCEPT { return etl::absolute(value); }