aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/Exceptions.hpp
diff options
context:
space:
mode:
authorsurmeh01 <surabhi.mehta@arm.com>2018-05-18 16:31:43 +0100
committertelsoa01 <telmo.soares@arm.com>2018-05-23 13:09:07 +0100
commit3537c2ca7ebf31c1673b9ec2bb0c17b0406bbae0 (patch)
tree5950603ad78ec3fe56fb31ddc7f4d52a19f5bc60 /include/armnn/Exceptions.hpp
parentbceff2fb3fc68bb0aa88b886900c34b77340c826 (diff)
downloadarmnn-3537c2ca7ebf31c1673b9ec2bb0c17b0406bbae0.tar.gz
Release 18.05
Diffstat (limited to 'include/armnn/Exceptions.hpp')
-rw-r--r--include/armnn/Exceptions.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/armnn/Exceptions.hpp b/include/armnn/Exceptions.hpp
index 0b043997c4..630c77660d 100644
--- a/include/armnn/Exceptions.hpp
+++ b/include/armnn/Exceptions.hpp
@@ -6,6 +6,7 @@
#include <stdexcept>
#include <string>
+#include <sstream>
namespace armnn
{
@@ -72,4 +73,22 @@ void ConditionalThrow(bool condition, const std::string& message)
}
}
+///
+/// ComparedType must support:
+/// operator==(const ComparedType&)
+/// operator<<(ostream&, const ComparedType&)
+///
+template <typename ExceptionType, typename ComparedType>
+void ConditionalThrowIfNotEqual(const std::string& message,
+ const ComparedType& leftHandSide,
+ const ComparedType& rightHandSide)
+{
+ if (!(leftHandSide == rightHandSide))
+ {
+ std::stringstream ss;
+ ss << message << " : " << leftHandSide << " != " << rightHandSide;
+ throw ExceptionType(ss.str());
+ }
+}
+
}