From f34debbbc5228982ec7e62f9f93b27039fa1b711 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Mon, 8 Dec 2014 20:16:55 +0000 Subject: [PATCH] Changed to stddef.h Renamed exception macro --- cyclic_value.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++- deque.h | 2 +- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/cyclic_value.h b/cyclic_value.h index 90be5006..da65b7a4 100644 --- a/cyclic_value.h +++ b/cyclic_value.h @@ -29,7 +29,7 @@ SOFTWARE. #ifndef __ETL_CYCLIC_VALUE__ #define __ETL_CYCLIC_VALUE__ -#include +#include ///\defgroup cyclic_value cyclic_value /// Provides a value that cycles between two limits. @@ -55,6 +55,8 @@ namespace etl { public: + template friend class cyclic_value; + //************************************************************************* /// Constructor. /// Sets 'first' and 'last' to the template parameter values. @@ -207,6 +209,27 @@ namespace etl return temp; } + //************************************************************************* + /// = operator. + //************************************************************************* + cyclic_value& operator =(T t) + { + value = t; + return *this; + } + + //************************************************************************* + /// = operator. + //************************************************************************* + template + cyclic_value& operator =(const cyclic_value& other) + { + value = other.value; + first_value = other.first_value; + last_value = other.last_value; + return *this; + } + //************************************************************************* /// Gets the first value. //************************************************************************* @@ -223,12 +246,53 @@ namespace etl return last_value; } + //************************************************************************* + /// Swaps the values. + //************************************************************************* + template + void swap(cyclic_value& other) + { + std::swap(first_value, other.first_value); + std::swap(last_value, other.last_value); + std::swap(value, other.value); + } + private: T value; ///< The current value. T first_value; ///< The first value in the range. T last_value; ///< The last value in the range. }; + + //************************************************************************* + /// Swaps the values. + //************************************************************************* + template + void swap(cyclic_value& lhs, + cyclic_value& rhs) + { + lhs.swap(rhs); + } + + //************************************************************************* + /// Equality operator. + //************************************************************************* + template + bool operator == (const cyclic_value& lhs, + const cyclic_value& rhs) + { + return static_cast(lhs) == static_cast(rhs); + } + + //************************************************************************* + /// Inequality operator. + //************************************************************************* + template + bool operator != (const cyclic_value& lhs, + const cyclic_value& rhs) + { + return !(lhs == rhs); + } } #endif diff --git a/deque.h b/deque.h index a373ddb7..531d13ac 100644 --- a/deque.h +++ b/deque.h @@ -29,7 +29,7 @@ SOFTWARE. #ifndef __ETL_DEQUE__ #define __ETL_DEQUE__ -#include +#include #include #include