From a3588b292dd0c96e791b4c436af661b132ec01eb Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sat, 22 Aug 2015 19:01:21 +0200
Subject: [PATCH] simplify compare

---
 alib2data/src/common/base.hpp | 61 ++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/alib2data/src/common/base.hpp b/alib2data/src/common/base.hpp
index 4cc682bab1..ddc6bd6284 100644
--- a/alib2data/src/common/base.hpp
+++ b/alib2data/src/common/base.hpp
@@ -14,66 +14,69 @@
 
 namespace alib {
 
-template<typename T>
+template < typename T >
 class base {
 public:
-	virtual ~base() noexcept {}
+	virtual ~base ( ) noexcept { }
 
-	virtual long long selfTypeId() const = 0;
+	virtual long long selfTypeId ( ) const = 0;
 
-	virtual T* clone() const = 0;
+	virtual T * clone ( ) const = 0;
 
-	virtual T* plunder() && = 0;
+	virtual T * plunder ( ) && = 0;
 
-	bool operator!=(const T& other) const {
-		return this->compare(other) != 0;
+	bool operator !=( const T & other ) const {
+		return this->compare ( other ) != 0;
 	}
 
-	bool operator==(const T & other) const {
-		return this->compare(other) == 0;
+	bool operator ==( const T & other ) const {
+		return this->compare ( other ) == 0;
 	}
 
-	bool operator<(const T & other) const {
-		return this->compare(other) < 0;
+	bool operator <( const T & other ) const {
+		return this->compare ( other ) < 0;
 	}
 
-	bool operator<=(const T & other) const {
-		return this->compare(other) <= 0;
+	bool operator <=( const T & other ) const {
+		return this->compare ( other ) <= 0;
 	}
 
-	bool operator>(const T & other) const {
-		return this->compare(other) > 0;
+	bool operator >( const T & other ) const {
+		return this->compare ( other ) > 0;
 	}
 
-	bool operator>=(const T & other) const {
-		return this->compare(other) >= 0;
+	bool operator >=( const T & other ) const {
+		return this->compare ( other ) >= 0;
 	}
 
-	virtual int compare(const T & other) const = 0;
+	virtual int compare ( const T & other ) const = 0;
 
-	template<typename R, typename S> //TODO what if someone want to control the ordering?
-	static int compare(const R& first, const S& second) {
-		if(first.selfTypeId() < second.selfTypeId())
+	template < typename R >
+
+	 // TODO what if someone want to control the ordering?
+	static int compare ( const R & first, const T & second ) {
+		if ( first.selfTypeId ( ) < second.selfTypeId ( ) )
 			return -1;
-		else if(first.selfTypeId() > second.selfTypeId())
+		else if ( first.selfTypeId ( ) > second.selfTypeId ( ) )
 			return 1;
 		else
-			return first.compare((const R&) second);
+			return first.compare ( ( const R & ) second );
 	}
 
-	friend std::ostream& operator<<(std::ostream& os, const T & instance) {
+	friend std::ostream & operator <<( std::ostream & os, const T & instance ) {
 		instance >> os;
 		return os;
 	}
 
-	virtual void operator>>(std::ostream&) const = 0;
+	virtual void operator >>( std::ostream & ) const = 0;
 
-	virtual explicit operator std::string () const = 0;
+	virtual explicit operator std::string ( ) const = 0;
 
-	template<typename R>
-	static long long typeId(const R&) {
-		return (long long) &base::typeId<R>;
+	template < typename R >
+	static long long typeId ( const R & ) {
+		return ( long long ) & base::typeId < R >;
 	}
+
 };
 
 } /* namespace alib */
-- 
GitLab