From 48c496cd44c6ed2ef590450f61c7a5e184abd190 Mon Sep 17 00:00:00 2001 From: Drew Rife Date: Wed, 13 Mar 2024 05:56:47 -0400 Subject: [PATCH 1/3] Implement Constexpr Strong Typedef (#861) * feat: make type_def constexpr * test: macro constexpr * test: implicit constexpr * test: get constexpr * refactor: remove constexpr from assignment * test: comparisons constexpr * fix: cpp11 support for constexpr get method --- include/etl/type_def.h | 34 ++++++++++++-------- test/test_type_def.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 13 deletions(-) diff --git a/include/etl/type_def.h b/include/etl/type_def.h index d16e4cd9..9b003313 100644 --- a/include/etl/type_def.h +++ b/include/etl/type_def.h @@ -58,25 +58,25 @@ namespace etl typedef TIdType id_type; //********************************************************************* - type_def() + ETL_CONSTEXPR type_def() : value(TValue()) { } //********************************************************************* - type_def(TValue value_) + ETL_CONSTEXPR type_def(TValue value_) : value(value_) { } //********************************************************************* - type_def(const type_def& other) + ETL_CONSTEXPR type_def(const type_def& other) : value(other.value) { } //********************************************************************* - operator TValue() const + ETL_CONSTEXPR operator TValue() const { return value; } @@ -238,63 +238,71 @@ namespace etl } //********************************************************************* - type_def& operator =(TValue rhs) + ETL_CONSTEXPR type_def& operator =(TValue rhs) { value = rhs; return *this; } //********************************************************************* - type_def& operator =(const type_def& rhs) + ETL_CONSTEXPR type_def& operator =(const type_def& rhs) { value = rhs.value; return *this; } //********************************************************************* - TValue& get() + ETL_CONSTEXPR TValue& get() { return value; } +#if ETL_USING_CPP14 + //********************************************************************* + ETL_CONSTEXPR const TValue& get() const + { + return value; + } +#else //********************************************************************* const TValue& get() const { return value; } +#endif // ETL_USING_CPP14 //********************************************************************* - friend bool operator <(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator <(const type_def& lhs, const type_def& rhs) { return lhs.value < rhs.value; } //********************************************************************* - friend bool operator <=(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator <=(const type_def& lhs, const type_def& rhs) { return lhs.value <= rhs.value; } //********************************************************************* - friend bool operator >(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator >(const type_def& lhs, const type_def& rhs) { return lhs.value > rhs.value; } //********************************************************************* - friend bool operator >=(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator >=(const type_def& lhs, const type_def& rhs) { return lhs.value >= rhs.value; } //********************************************************************* - friend bool operator ==(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator ==(const type_def& lhs, const type_def& rhs) { return lhs.value == rhs.value; } //********************************************************************* - friend bool operator !=(const type_def& lhs, const type_def& rhs) + friend ETL_CONSTEXPR bool operator !=(const type_def& lhs, const type_def& rhs) { return lhs.value != rhs.value; } diff --git a/test/test_type_def.cpp b/test/test_type_def.cpp index 5cf9203b..b2f27172 100644 --- a/test/test_type_def.cpp +++ b/test/test_type_def.cpp @@ -51,6 +51,21 @@ namespace CHECK_EQUAL(i1, i2); } + //************************************************************************* + TEST(test_macro_constexpr) + { + ETL_TYPEDEF(uint32_t, type1_t); + ETL_TYPEDEF(uint32_t, type2_t); + + constexpr type1_t t1 = type1_t(1); + constexpr type2_t t2 = type2_t(1); + + uint32_t i1 = t1.get(); + uint32_t i2 = t2.get(); + + CHECK_EQUAL(i1, i2); + } + //************************************************************************* TEST(test_implicit) { @@ -69,6 +84,24 @@ namespace CHECK_EQUAL(i1, i2); } + //************************************************************************* + TEST(test_implicit_constexpr) + { + class type1_t_tag; + typedef etl::type_def type1_t; + + class type2_t_tag; + typedef etl::type_def type2_t; + + constexpr type1_t t1 = type1_t(1); + constexpr type2_t t2 = type2_t(1); + + uint32_t i1 = t1.get(); + uint32_t i2 = t2.get(); + + CHECK_EQUAL(i1, i2); + } + //************************************************************************* TEST(test_get) { @@ -84,6 +117,21 @@ namespace CHECK_EQUAL(t1.get(), t2.get()); } + //************************************************************************* + TEST(test_get_constexpr) + { + class type1_t_tag; + typedef etl::type_def type1_t; + + class type2_t_tag; + typedef etl::type_def type2_t; + + constexpr type1_t t1(1); + constexpr type2_t t2(1); + + CHECK_EQUAL(t1.get(), t2.get()); + } + //************************************************************************* TEST(test_operators) { @@ -141,5 +189,28 @@ namespace CHECK(!(t1 >= t2)); CHECK(t2 >= t4); } + + //************************************************************************* + TEST(test_comparisons_constexpr) + { + class __type_t__; + typedef etl::type_def<__type_t__, uint32_t> type_t; + + constexpr type_t t1(1); + constexpr type_t t2(2); + constexpr type_t t3(t1); + constexpr type_t t4(t2); + + CHECK(t1 < t2); + CHECK(!(t2 < t1)); + CHECK(t1 <= t2); + CHECK(!(t2 <= t1)); + CHECK(t1 <= t3); + CHECK(t2 > t1); + CHECK(!(t1 > t2)); + CHECK(t2 >= t1); + CHECK(!(t1 >= t2)); + CHECK(t2 >= t4); + } }; } From a8ca216f4e92356c45502fe69f30c759c88acde8 Mon Sep 17 00:00:00 2001 From: Drew Rife Date: Sat, 16 Mar 2024 08:07:00 -0400 Subject: [PATCH 2/3] Update ETL_CONSTEXPR and C++14 desgination from type_def (#862) * feat: make type_def constexpr * test: macro constexpr * test: implicit constexpr * test: get constexpr * refactor: remove constexpr from assignment * test: comparisons constexpr * fix: cpp11 support for constexpr get method * fix: c++11 issue with constexpr get reference * refactor: remove constexpr from the get methods * refactor: make assignment operators non-constexpr * refactor: remove constexpr from assignment and get * refactor: make other methods ETL_CONSTEXPR14 * test: operator preincrement * test: postincrement * test: predecrement constexpr * test: post decrement constexpr * fix: post decrement test * test: addition assignment constexpr * test: subtraction assignment constexpr * test: multiplication assignment operator * test: and assignment constexpr * test: or assignment constexpr * test: xor assignment constexpr * tet: left shift assignment constexpr * test: right shift assignment constexpr * test: operator modules assignment * style: revert personal clang-format changes * refactor: use free functions to test * refactor: remove constexpr non-constexpr test functions * style: remove erroneous tab --- include/etl/type_def.h | 60 ++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/include/etl/type_def.h b/include/etl/type_def.h index 9b003313..7cb5c246 100644 --- a/include/etl/type_def.h +++ b/include/etl/type_def.h @@ -82,14 +82,14 @@ namespace etl } //********************************************************************* - type_def& operator ++() + ETL_CONSTEXPR14 type_def& operator ++() { ++value; return *this; } //********************************************************************* - type_def operator ++(int) + ETL_CONSTEXPR14 type_def operator ++(int) { type_def temp(*this); type_def::operator ++(); @@ -97,14 +97,14 @@ namespace etl } //********************************************************************* - type_def& operator --() + ETL_CONSTEXPR14 type_def& operator --() { --value; return *this; } //********************************************************************* - type_def operator --(int) + ETL_CONSTEXPR14 type_def operator --(int) { type_def temp(*this); type_def::operator --(); @@ -112,164 +112,156 @@ namespace etl } //********************************************************************* - type_def& operator +=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator +=(TValue rhs) { value += rhs; return *this; } //********************************************************************* - type_def& operator +=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator +=(const type_def& rhs) { value += rhs.value; return *this; } //********************************************************************* - type_def& operator -=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator -=(TValue rhs) { value -= rhs; return *this; } //********************************************************************* - type_def& operator -=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator -=(const type_def& rhs) { value -= rhs.value; return *this; } //********************************************************************* - type_def& operator *=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator *=(TValue rhs) { value *= rhs; return *this; } //********************************************************************* - type_def& operator *=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator *=(const type_def& rhs) { value *= rhs.value; return *this; } //********************************************************************* - type_def& operator /=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator /=(TValue rhs) { value /= rhs; return *this; } //********************************************************************* - type_def& operator /=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator /=(const type_def& rhs) { value /= rhs.value; return *this; } //********************************************************************* - type_def& operator %=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator %=(TValue rhs) { value %= rhs; return *this; } //********************************************************************* - type_def& operator %=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator %=(const type_def& rhs) { value %= rhs.value; return *this; } //********************************************************************* - type_def& operator &=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator &=(TValue rhs) { value &= rhs; return *this; } //********************************************************************* - type_def& operator &=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator &=(const type_def& rhs) { value &= rhs.value; return *this; } //********************************************************************* - type_def& operator |=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator |=(TValue rhs) { value |= rhs; return *this; } //********************************************************************* - type_def& operator |=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator |=(const type_def& rhs) { value |= rhs.value; return *this; } //********************************************************************* - type_def& operator ^=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator ^=(TValue rhs) { value ^= rhs; return *this; } //********************************************************************* - type_def& operator ^=(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator ^=(const type_def& rhs) { value ^= rhs.value; return *this; } //********************************************************************* - type_def& operator <<=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator <<=(TValue rhs) { value <<= rhs; return *this; } //********************************************************************* - type_def& operator >>=(TValue rhs) + ETL_CONSTEXPR14 type_def& operator >>=(TValue rhs) { value >>= rhs; return *this; } //********************************************************************* - ETL_CONSTEXPR type_def& operator =(TValue rhs) + ETL_CONSTEXPR14 type_def& operator =(TValue rhs) { value = rhs; return *this; } //********************************************************************* - ETL_CONSTEXPR type_def& operator =(const type_def& rhs) + ETL_CONSTEXPR14 type_def& operator =(const type_def& rhs) { value = rhs.value; return *this; } //********************************************************************* - ETL_CONSTEXPR TValue& get() + ETL_CONSTEXPR14 TValue& get() { return value; } -#if ETL_USING_CPP14 //********************************************************************* - ETL_CONSTEXPR const TValue& get() const + ETL_CONSTEXPR14 const TValue& get() const { return value; } -#else - //********************************************************************* - const TValue& get() const - { - return value; - } -#endif // ETL_USING_CPP14 //********************************************************************* friend ETL_CONSTEXPR bool operator <(const type_def& lhs, const type_def& rhs) From 15675f29a66151faaffa2f964b897826ec1c7d82 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Mar 2024 13:56:56 +0000 Subject: [PATCH 3/3] Updates to constexpr operators --- include/etl/type_def.h | 450 ++++++++++++++++++++--------------------- test/test_type_def.cpp | 69 +++++-- 2 files changed, 276 insertions(+), 243 deletions(-) diff --git a/include/etl/type_def.h b/include/etl/type_def.h index 7cb5c246..c124aa7e 100644 --- a/include/etl/type_def.h +++ b/include/etl/type_def.h @@ -35,274 +35,262 @@ SOFTWARE. namespace etl { - #define ETL_TYPEDEF(T, name) class name##_tag; typedef etl::type_def name + #define ETL_TYPEDEF(T, name) class name##_tag; typedef etl::type_def name - //************************************************************************* - /// A template type to define strong typedefs. - /// Usage: - ///\code - /// // Short form. - /// ETL_TYPEDEF(int, mytype); - /// - /// // Long form. - /// class mytype_t_tag; - /// typedef etl::type_def mytype_t_tag; - ///\endcode - //************************************************************************* - template - class type_def + //************************************************************************* + /// A template type to define strong typedefs. + /// Usage: + ///\code + /// // Short form. + /// ETL_TYPEDEF(int, mytype); + /// + /// // Long form. + /// class mytype_t_tag; + /// typedef etl::type_def mytype_t_tag; + ///\endcode + //************************************************************************* + template + class type_def + { + public: + + typedef TValue value_type; + typedef TIdType id_type; + + //********************************************************************* + ETL_CONSTEXPR type_def() + : value(TValue()) { - public: + } - typedef TValue value_type; - typedef TIdType id_type; + //********************************************************************* + ETL_CONSTEXPR type_def(TValue value_) + : value(value_) + { + } - //********************************************************************* - ETL_CONSTEXPR type_def() - : value(TValue()) - { - } + //********************************************************************* + ETL_CONSTEXPR type_def(const type_def& other) + : value(other.value) + { + } - //********************************************************************* - ETL_CONSTEXPR type_def(TValue value_) - : value(value_) - { - } + //********************************************************************* + ETL_CONSTEXPR operator TValue() const + { + return value; + } - //********************************************************************* - ETL_CONSTEXPR type_def(const type_def& other) - : value(other.value) - { - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator ++() + { + ++value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR operator TValue() const - { - return value; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def operator ++(int) + { + type_def temp(*this); + type_def::operator ++(); + return temp; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator ++() - { - ++value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator --() + { + --value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def operator ++(int) - { - type_def temp(*this); - type_def::operator ++(); - return temp; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def operator --(int) + { + type_def temp(*this); + type_def::operator --(); + return temp; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator --() - { - --value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator +=(TValue rhs) + { + value += rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def operator --(int) - { - type_def temp(*this); - type_def::operator --(); - return temp; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator +=(const type_def& rhs) + { + value += rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator +=(TValue rhs) - { - value += rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator -=(TValue rhs) + { + value -= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator +=(const type_def& rhs) - { - value += rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator -=(const type_def& rhs) + { + value -= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator -=(TValue rhs) - { - value -= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator *=(TValue rhs) + { + value *= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator -=(const type_def& rhs) - { - value -= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator *=(const type_def& rhs) + { + value *= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator *=(TValue rhs) - { - value *= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator /=(TValue rhs) + { + value /= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator *=(const type_def& rhs) - { - value *= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator /=(const type_def& rhs) + { + value /= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator /=(TValue rhs) - { - value /= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator %=(TValue rhs) + { + value %= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator /=(const type_def& rhs) - { - value /= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator %=(const type_def& rhs) + { + value %= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator %=(TValue rhs) - { - value %= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator &=(TValue rhs) + { + value &= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator %=(const type_def& rhs) - { - value %= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator &=(const type_def& rhs) + { + value &= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator &=(TValue rhs) - { - value &= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator |=(TValue rhs) + { + value |= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator &=(const type_def& rhs) - { - value &= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator |=(const type_def& rhs) + { + value |= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator |=(TValue rhs) - { - value |= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator ^=(TValue rhs) + { + value ^= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator |=(const type_def& rhs) - { - value |= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator ^=(const type_def& rhs) + { + value ^= rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator ^=(TValue rhs) - { - value ^= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator <<=(TValue rhs) + { + value <<= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator ^=(const type_def& rhs) - { - value ^= rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator >>=(TValue rhs) + { + value >>= rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator <<=(TValue rhs) - { - value <<= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator =(TValue rhs) + { + value = rhs; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator >>=(TValue rhs) - { - value >>= rhs; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR14 type_def& operator =(const type_def& rhs) + { + value = rhs.value; + return *this; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator =(TValue rhs) - { - value = rhs; - return *this; - } + //********************************************************************* + TValue& get() + { + return value; + } - //********************************************************************* - ETL_CONSTEXPR14 type_def& operator =(const type_def& rhs) - { - value = rhs.value; - return *this; - } + //********************************************************************* + ETL_CONSTEXPR const TValue& get() const + { + return value; + } - //********************************************************************* - ETL_CONSTEXPR14 TValue& get() - { - return value; - } + //********************************************************************* + friend ETL_CONSTEXPR bool operator >(const type_def& lhs, const type_def& rhs) + { + return lhs.value > rhs.value; + } - //********************************************************************* - ETL_CONSTEXPR14 const TValue& get() const - { - return value; - } + //********************************************************************* + friend ETL_CONSTEXPR bool operator >=(const type_def& lhs, const type_def& rhs) + { + return lhs.value >= rhs.value; + } - //********************************************************************* - friend ETL_CONSTEXPR bool operator <(const type_def& lhs, const type_def& rhs) - { - return lhs.value < rhs.value; - } + //********************************************************************* + friend ETL_CONSTEXPR bool operator ==(const type_def& lhs, const type_def& rhs) + { + return lhs.value == rhs.value; + } - //********************************************************************* - friend ETL_CONSTEXPR bool operator <=(const type_def& lhs, const type_def& rhs) - { - return lhs.value <= rhs.value; - } + //********************************************************************* + friend ETL_CONSTEXPR bool operator !=(const type_def& lhs, const type_def& rhs) + { + return lhs.value != rhs.value; + } - //********************************************************************* - friend ETL_CONSTEXPR bool operator >(const type_def& lhs, const type_def& rhs) - { - return lhs.value > rhs.value; - } + private: - //********************************************************************* - friend ETL_CONSTEXPR bool operator >=(const type_def& lhs, const type_def& rhs) - { - return lhs.value >= rhs.value; - } - - //********************************************************************* - friend ETL_CONSTEXPR bool operator ==(const type_def& lhs, const type_def& rhs) - { - return lhs.value == rhs.value; - } - - //********************************************************************* - friend ETL_CONSTEXPR bool operator !=(const type_def& lhs, const type_def& rhs) - { - return lhs.value != rhs.value; - } - - private: - - TValue value; - }; + TValue value; + }; } #endif diff --git a/test/test_type_def.cpp b/test/test_type_def.cpp index b2f27172..8ce542e0 100644 --- a/test/test_type_def.cpp +++ b/test/test_type_def.cpp @@ -32,6 +32,8 @@ SOFTWARE. #include "etl/type_def.h" +#include "etl/type_traits.h" + namespace { SUITE(test_type_def) @@ -198,19 +200,62 @@ namespace constexpr type_t t1(1); constexpr type_t t2(2); - constexpr type_t t3(t1); - constexpr type_t t4(t2); - CHECK(t1 < t2); - CHECK(!(t2 < t1)); - CHECK(t1 <= t2); - CHECK(!(t2 <= t1)); - CHECK(t1 <= t3); - CHECK(t2 > t1); - CHECK(!(t1 > t2)); - CHECK(t2 >= t1); - CHECK(!(t1 >= t2)); - CHECK(t2 >= t4); + constexpr bool eq = t1 == t1; + constexpr bool neq = t1 == t2; + constexpr bool lt = t1 < t2; + constexpr bool nlt = t2 < t1; + constexpr bool lte = t1 <= t2; + constexpr bool nlte = t2 <= t1; + constexpr bool gt = t1 > t2; + constexpr bool ngt = t2 > t1; + constexpr bool gte = t1 >= t2; + constexpr bool ngte = t2 >= t1; + + CHECK_TRUE(eq); + CHECK_FALSE(neq); + CHECK_TRUE(lt); + CHECK_FALSE(nlt); + CHECK_TRUE(lte); + CHECK_FALSE(nlte); + CHECK_FALSE(gt); + CHECK_TRUE(ngt); + CHECK_FALSE(gte); + CHECK_TRUE(ngte); + } + + //************************************************************************* + ETL_TYPEDEF(int32_t, arithmetic_type_t); + + constexpr arithmetic_type_t CreatePlus() + { + arithmetic_type_t value = 0; + + ++value; + value++; + value += 1; + + return value; + } + + constexpr arithmetic_type_t CreateMinus() + { + arithmetic_type_t value = 0; + + --value; + value--; + value -= 1; + + return value; + } + + TEST(test_arithmetic_constexpr) + { + constexpr arithmetic_type_t value_plus = CreatePlus(); + constexpr arithmetic_type_t value_minus = CreateMinus(); + + CHECK_EQUAL(3, value_plus.get()); + CHECK_EQUAL(-3, value_minus.get()); } }; }