diff options
Diffstat (limited to 'Utilities/std/cmext/memory')
-rw-r--r-- | Utilities/std/cmext/memory | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Utilities/std/cmext/memory b/Utilities/std/cmext/memory index 540a3de..50e79df 100644 --- a/Utilities/std/cmext/memory +++ b/Utilities/std/cmext/memory @@ -6,6 +6,8 @@ #ifndef cmext_memory #define cmext_memory +#include <typeinfo> + #include <cm/type_traits> namespace cm { @@ -24,7 +26,13 @@ template <typename T, typename O, int> = 0> T& dynamic_reference_cast(O& item) { - return *(dynamic_cast<T*>(item.get())); + auto p = dynamic_cast<T*>(item.get()); + + if (p == nullptr) { + throw std::bad_cast(); + } + + return *p; } } // namespace cm |