From 2ef8e0d364d2e557f28a316c39e3ecb3331bdba0 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Mon, 18 Mar 2019 01:42:32 +0200
Subject: [PATCH] Use static type checking to prevent RTTI

---
 inc/ErrorHandler.hpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp
index d01471bf..11fd17a9 100644
--- a/inc/ErrorHandler.hpp
+++ b/inc/ErrorHandler.hpp
@@ -1,6 +1,8 @@
 #ifndef PROJECT_ERRORHANDLER_HPP
 #define PROJECT_ERRORHANDLER_HPP
 
+#include <type_traits>
+
 // Forward declaration of the class, since its header file depends on the ErrorHandler
 class Message;
 
@@ -217,19 +219,19 @@ public:
 		// While this may seem like a "hacky" way to convert enums to ErrorSource, it should be
 		// optimised by the compiler to constant time.
 
-		if (typeid(ErrorType) == typeid(AcceptanceErrorType)) {
+		if (std::is_same<ErrorType, AcceptanceErrorType>()) {
 			return Acceptance;
 		}
-		if (typeid(ErrorType) == typeid(ExecutionStartErrorType)) {
+		if (std::is_same<ErrorType, ExecutionStartErrorType>()) {
 			return ExecutionStart;
 		}
-		if (typeid(ErrorType) == typeid(ExecutionProgressErrorType)) {
+		if (std::is_same<ErrorType, ExecutionProgressErrorType>()) {
 			return ExecutionProgress;
 		}
-		if (typeid(ErrorType) == typeid(ExecutionCompletionErrorType)) {
+		if (std::is_same<ErrorType, ExecutionCompletionErrorType>()) {
 			return ExecutionCompletion;
 		}
-		if (typeid(ErrorType) == typeid(RoutingErrorType)) {
+		if (std::is_same<ErrorType, RoutingErrorType>()) {
 			return Routing;
 		}
 		return Internal;
-- 
GitLab