From 4d4e0e2530629ae9ecfcb379bf0f27c6b18b6891 Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Wed, 19 Feb 2020 13:30:47 +0000 Subject: IVGCVSW-4483 Introduce polymorphic_downcast implementation Change-Id: I958dd719162337eb5c7e71f4ac49dd5784564b1a Signed-off-by: Derek Lamberti --- include/armnn/Exceptions.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/armnn/Exceptions.hpp') diff --git a/include/armnn/Exceptions.hpp b/include/armnn/Exceptions.hpp index cb62079b76..05b740614d 100644 --- a/include/armnn/Exceptions.hpp +++ b/include/armnn/Exceptions.hpp @@ -143,6 +143,13 @@ public: using Exception::Exception; }; +class PolymorphicDowncastException : public Exception +{ +public: + using Exception::Exception; +}; + + template void ConditionalThrow(bool condition, const std::string& message) { @@ -152,6 +159,16 @@ void ConditionalThrow(bool condition, const std::string& message) } } +template +void ConditionalThrow(bool condition) +{ + if (!condition) + { + throw ExceptionType(); + } +} + + /// /// ComparedType must support: /// operator==(const ComparedType&) -- cgit v1.2.1