mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 16:33:35 +08:00
Added try_implicit_cast<>() to check callbacks validness at run time
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user