From 072c5d2dd040bcb38f8a39be80149803097c2adf Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sun, 23 Nov 2014 13:00:25 +0100
Subject: [PATCH] simplify variant

---
 alib2data/src/std/variant.hpp | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/alib2data/src/std/variant.hpp b/alib2data/src/std/variant.hpp
index d780330d73..df432ef365 100644
--- a/alib2data/src/std/variant.hpp
+++ b/alib2data/src/std/variant.hpp
@@ -62,14 +62,6 @@ struct variant_helper<F, Ts...> {
 			variant_helper<Ts...>::move(old_t, old_v, new_v);
 	}
 
-	inline static bool compareEq(size_t this_t, const void * this_v, size_t other_t, const void * other_v)
-	{
-		if (this_t == typeid(F).hash_code())
-			return this_t == other_t && *(reinterpret_cast<const F*>(this_v)) == *(reinterpret_cast<const F*>(other_v));
-		else
-			return variant_helper<Ts...>::compareEq(this_t, this_v, other_t, other_v);
-	}
-
 	inline static void print(ostream& out, const size_t id, const void* data) {
 		if (id == typeid(F).hash_code())
 			out << *reinterpret_cast<const F*>(data);
@@ -84,17 +76,6 @@ struct variant_helper<F, Ts...> {
 			return variant_helper<Ts...>::string(id, data);
 	}
 
-	inline static bool compareLess(size_t this_t, const void * this_v, size_t other_t, const void * other_v)
-	{
-		if (this_t == typeid(F).hash_code() && other_t != typeid(F).hash_code()) return true;
-		if (this_t != typeid(F).hash_code() && other_t == typeid(F).hash_code()) return false;
-
-		if (this_t == typeid(F).hash_code() && other_t == typeid(F).hash_code())
-			return *(reinterpret_cast<const F*>(this_v)) < *(reinterpret_cast<const F*>(other_v));
-		else
-			return variant_helper<Ts...>::compareLess(this_t, this_v, other_t, other_v);
-	}
-
 	inline static int compareHelper(size_t this_t, const void * this_v, size_t other_t, const void * other_v)
 	{
 		if (this_t == typeid(F).hash_code() && other_t != typeid(F).hash_code()) return -1;
@@ -112,10 +93,8 @@ template<> struct variant_helper<>  {
 inline static void destroy(size_t, void *) { }
 inline static void copy(size_t, const void *, void *) { }
 inline static void move(size_t, void *, void *) { }
-inline static bool compareEq(size_t, const void *, size_t, const void *) { return true; }
 inline static void print(ostream&, const size_t, const void *) {}
 inline static std::string string(const size_t, const void *) { return ""; }
-inline static bool compareLess(size_t, const void *, size_t, const void *) { return false; }
 inline static int compareHelper(size_t, const void *, size_t, const void *) { return 0; }
 };
 
@@ -180,7 +159,7 @@ public:
 
 	bool operator== (const variant<Ts...>& other) const
 	{
-		return helper_t::compareEq(this->type_id, &this->data, other.type_id, &other.data);
+		return helper_t::compareHelper(this->type_id, &this->data, other.type_id, &other.data) == 0;
 	}
 
 	bool operator!= (const variant<Ts...>& other) const
@@ -190,7 +169,7 @@ public:
 
 	bool operator< (const variant<Ts...>& other) const
 	{
-		return helper_t::compareLess(this->type_id, &this->data, other.type_id, &other.data);
+		return helper_t::compareHelper(this->type_id, &this->data, other.type_id, &other.data) < 0;
 	}
 
 	bool operator> (const variant<Ts...>& other) const
-- 
GitLab