From a8ca216f4e92356c45502fe69f30c759c88acde8 Mon Sep 17 00:00:00 2001 From: Drew Rife Date: Sat, 16 Mar 2024 08:07:00 -0400 Subject: [PATCH] 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)