diff options
Diffstat (limited to 'include/armnn/Exceptions.hpp')
-rw-r--r-- | include/armnn/Exceptions.hpp | 19 |
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()); + } +} + } |