diff --git a/src/type_def.h b/src/type_def.h index 66d6156e..707a0732 100644 --- a/src/type_def.h +++ b/src/type_def.h @@ -40,11 +40,11 @@ namespace etl /// Usage: ///\code /// // Short form. - /// ETL_TYPEDEF(int, mytype); + /// ETL_TYPEDEF(int, mytype_t); /// /// // Long form. /// class mytype_t_tag; - /// typedef etl::type_def mytype_t_tag; + /// typedef etl::type_def mytype_t; ///\endcode //************************************************************************* template @@ -79,6 +79,18 @@ namespace etl return value; } + //********************************************************************* + explicit operator bool() const + { + return static_cast(value); + } + + //********************************************************************* + bool operator !() const + { + return !bool(value); + } + //********************************************************************* type_def& operator ++() { @@ -243,11 +255,35 @@ namespace etl } //********************************************************************* - TValue get() const + const TValue& get() const { return value; } + //********************************************************************* + friend type_def operator +(const type_def& lhs, const type_def& rhs) + { + return type_def(lhs.value + rhs.value); + } + + //********************************************************************* + friend type_def operator -(const type_def& lhs, const type_def& rhs) + { + return type_def(lhs.value - rhs.value); + } + + //********************************************************************* + friend type_def operator *(const type_def& lhs, const type_def& rhs) + { + return type_def(lhs.value * rhs.value); + } + + //********************************************************************* + friend type_def operator /(const type_def& lhs, const type_def& rhs) + { + return type_def(lhs.value / rhs.value); + } + //********************************************************************* friend bool operator <(const type_def& lhs, const type_def& rhs) {