B
baltasarq
Hi, there !
When I use dynamic_cast for a single object, I do something like:
void foo(Base *base)
{
if ( dynamic_cast<Derived *>( base ) != NULL ) {
((Derived *) base)->do_something()
}
}
I know it's better to avoid abuse of dynamic_cast, user virtual
functions, and so on.
However, I think it would be more practical to be able to write
something like:
if ( istypeof<Derived>( base ) ) {
}
I find the dynamic_cast style (actually, all '*_cast<>"), to take too
much characters to be written, and this is specially annoying in
formatting, for example.
Is there somehting like this within the proposals for the new
standard ?
(or maybe there is already something like this in the current
standard)
Regards,
Baltasar
When I use dynamic_cast for a single object, I do something like:
void foo(Base *base)
{
if ( dynamic_cast<Derived *>( base ) != NULL ) {
((Derived *) base)->do_something()
}
}
I know it's better to avoid abuse of dynamic_cast, user virtual
functions, and so on.
However, I think it would be more practical to be able to write
something like:
if ( istypeof<Derived>( base ) ) {
}
I find the dynamic_cast style (actually, all '*_cast<>"), to take too
much characters to be written, and this is specially annoying in
formatting, for example.
Is there somehting like this within the proposals for the new
standard ?
(or maybe there is already something like this in the current
standard)
Regards,
Baltasar