mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-30 06:18:50 +08:00
Added +-*/ operators.
Added bool conversion operator. Added ! operator. get() returns const reference.
This commit is contained in:
parent
ae2e4609b2
commit
ad0e3c4f8d
@ -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, int> mytype_t_tag;
|
||||
/// typedef etl::type_def<mytype_t_tag, int> mytype_t;
|
||||
///\endcode
|
||||
//*************************************************************************
|
||||
template <typename TIdType, typename TValue>
|
||||
@ -79,6 +79,18 @@ namespace etl
|
||||
return value;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
explicit operator bool() const
|
||||
{
|
||||
return static_cast<bool>(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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user