From 44df80219b88ab4d76b1c094f89d99a7e4f3b168 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 23 Jan 2025 09:37:40 +0000 Subject: [PATCH] Changed 'value' to 'type' Added C++14 constant tests --- include/etl/ratio.h | 28 ++++++++++++++-------------- test/test_ratio.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/include/etl/ratio.h b/include/etl/ratio.h index 1035e774..738fdfb7 100644 --- a/include/etl/ratio.h +++ b/include/etl/ratio.h @@ -143,7 +143,7 @@ namespace etl public: - using value = ratio; + using type = ratio; }; template @@ -155,14 +155,14 @@ namespace etl public: - using value = typename ratio_reduce>::value; + using type = typename ratio_reduce>::type; }; template struct ratio_subtract { public: - using value = typename ratio_add>::value; + using type = typename ratio_add>::type; }; template @@ -173,51 +173,51 @@ namespace etl static ETL_CONSTEXPR11 intmax_t gcd2 = etl::private_ratio::ratio_gcd::value; public: - using value = ratio<(R1::num / gcd1) * (R2::num / gcd2), (R1::den / gcd2) * (R2::den / gcd1)>; + using type = ratio<(R1::num / gcd1) * (R2::num / gcd2), (R1::den / gcd2) * (R2::den / gcd1)>; }; template struct ratio_divide { public: - using value = typename ratio_multiply>::value; + using type = typename ratio_multiply>::type; }; } template - using ratio_add = typename private_ratio::ratio_add::value; + using ratio_add = typename private_ratio::ratio_add::type; template - using ratio_subtract = typename private_ratio::ratio_subtract::value; + using ratio_subtract = typename private_ratio::ratio_subtract::type; template - using ratio_multiply = typename private_ratio::ratio_multiply::value; + using ratio_multiply = typename private_ratio::ratio_multiply::type; template - using ratio_divide = typename private_ratio::ratio_divide::value; + using ratio_divide = typename private_ratio::ratio_divide::type; template - struct ratio_equal: etl::integral_constant + struct ratio_equal : etl::integral_constant { }; template - struct ratio_not_equal: etl::integral_constant + struct ratio_not_equal : etl::integral_constant { }; template - struct ratio_less: etl::integral_constant + struct ratio_less : etl::integral_constant { }; template - struct ratio_less_equal: etl::integral_constant + struct ratio_less_equal : etl::integral_constant { }; template - struct ratio_greater: etl::integral_constant R2::num * R1::den)> + struct ratio_greater : etl::integral_constant R2::num * R1::den)> { }; diff --git a/test/test_ratio.cpp b/test/test_ratio.cpp index 12a0b406..863bd5cd 100644 --- a/test/test_ratio.cpp +++ b/test/test_ratio.cpp @@ -87,6 +87,11 @@ namespace CHECK((etl::ratio_equal::value)); CHECK((!etl::ratio_equal::value)); + +#if ETL_USING_CPP14 + CHECK((etl::ratio_equal_v)); + CHECK((!etl::ratio_equal_v)); +#endif } //************************************************************************* @@ -97,6 +102,11 @@ namespace CHECK((!etl::ratio_not_equal::value)); CHECK((etl::ratio_not_equal::value)); + +#if ETL_USING_CPP14 + CHECK((!etl::ratio_not_equal_v)); + CHECK((etl::ratio_not_equal_v)); +#endif } //************************************************************************* @@ -107,6 +117,11 @@ namespace CHECK((etl::ratio_less::value)); CHECK((!etl::ratio_less::value)); + +#if ETL_USING_CPP14 + CHECK((etl::ratio_less_v)); + CHECK((!etl::ratio_less_v)); +#endif } //************************************************************************* @@ -117,6 +132,11 @@ namespace CHECK((etl::ratio_less_equal::value)); CHECK((etl::ratio_less_equal::value)); + +#if ETL_USING_CPP14 + CHECK((etl::ratio_less_equal_v)); + CHECK((etl::ratio_less_equal_v)); +#endif } //************************************************************************* @@ -127,6 +147,11 @@ namespace CHECK((etl::ratio_greater::value)); CHECK((!etl::ratio_greater::value)); + +#if ETL_USING_CPP14 + CHECK((etl::ratio_greater_v)); + CHECK((!etl::ratio_greater_v)); +#endif } //************************************************************************* @@ -137,6 +162,11 @@ namespace CHECK((etl::ratio_greater_equal::value)); CHECK((etl::ratio_greater_equal::value)); + +#if ETL_USING_CPP14 + CHECK((etl::ratio_greater_equal_v)); + CHECK((etl::ratio_greater_equal_v)); +#endif } };