Commit b3489362 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Add a macro to static cast with dynamic cast checking in debug mode.

parent b885e4dc
......@@ -37,5 +37,14 @@
# define HPP_STATIC_PTR_CAST(t, x) boost::static_pointer_cast < t > (x)
# define HPP_DYNAMIC_PTR_CAST(t, x) boost::dynamic_pointer_cast < t > (x)
# ifndef NDEBUG
# define HPP_STATIC_CAST_REF_CHECK(t, x)\
try {\
dynamic_cast < t& > (x);\
} catch (const std::exception& exc) {\
assert ("Cast in #t failed" && 0);\
}
# else
# define HPP_STATIC_CAST_REF_CHECK(t, x)
# endif // defined NDEBUG
#endif //! HPP_UTIL_POINTER_HH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment