Commit bfb0d6dc authored by Xavier Thompson's avatar Xavier Thompson

Fix and improve 'isinstanceof' implementation

parent 250d8053
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <vector> #include <vector>
#include <type_traits>
struct ThreadStorage { struct ThreadStorage {
pid_t thread_id; pid_t thread_id;
...@@ -174,9 +176,10 @@ ...@@ -174,9 +176,10 @@
* template: * template:
* - T: the type * - T: the type
*/ */
template <typename T> template <typename T, typename O>
static inline int isinstanceof(CyObject * ob) { static inline int isinstanceof(O ob) {
return dynamic_cast<T *>(ob) != NULL; static_assert(std::is_convertible<T, CyObject *>::value, "wrong type 'T' for isinstanceof[T]");
return dynamic_cast<T>(ob) != NULL;
} }
/* /*
......
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