Added try_implicit_cast<>() to check callbacks validness at run time

This commit is contained in:
Pavel Kirienko
2014-03-09 13:47:07 +04:00
parent 0afb7f4eea
commit 1659b5c476
3 changed files with 43 additions and 3 deletions
@@ -9,6 +9,7 @@
#include <stdexcept>
#include <typeinfo>
#include <uavcan/internal/impl_constants.hpp>
#include <uavcan/internal/util.hpp>
namespace uavcan
{
@@ -24,7 +25,8 @@ public:
: obj_(o)
, fun_(f)
{
if (!o || !f)
if (!try_implicit_cast<bool>(o, true) ||
!try_implicit_cast<bool>(f, true))
{
#if UAVCAN_EXCEPTIONS
throw std::runtime_error(typeid(*this).name());