As my previous question i am trying to build a conditions to examine two types check if should i do dynamic_cast
or not. I had following conditions:
#define can_dynamic_cast(FROM, TO) \
can_cast(FROM, TO) && \
!std::is_same<FROM, TO>::value && \
std::is_class<TO>::value && \
!std::is_const<FROM>::value && \
std::is_base_of<TO, FROM>::value
It does not work for below basic check, the can_dynamic_cast
will return true!!!
static_assert(!can_dynamic_cast(int, int), "didn't expecting dynamic cast, but could!")
Out of desperation i came down to below conditions, but still no hope!!
#define can_dynamic_cast(FROM, TO) \
std::is_convertible<FROM, TO>::value && \
std::is_class<TO>::value && \
std::is_class<FROM>::value
The above conditions are the most basic conditions, can_dynamic_cast
will return true
for (int, int)
again, which is not suppose to!!!
Question
1) What am i don't wrong?
Aucun commentaire:
Enregistrer un commentaire