what do "most people" do with casts when they could be doing something else?
Your guess on pointer casts sound about right.
Consider this code:
class some_base { /* ... */ };
class some_implementation: public some_base
{ void do_impl_stuff() { /* ... */ } }; // do_impl code is in specialization
bad client code:
void do_stuff(some_base* base)
{
if(some_implementation* p = dynamic_cast<some_implementation*>(base)) {
p->do_impl_stuff();
}
}
better alternative:
class some_base
{
public:
virtual void do_impl_stuff() = 0;
virtual ~some_base() = default;
};
class some_implementation: public some_base
{ virtual void do_impl_stuff() override { /* ... */ } };
void do_stuff(some_base* base)
{
base->do_impl_stuff();
}
The first example "abuses" the dynamic cast. The second, is "doing something else"
Edit: The point Xephon is making is also valid.
Regarding overuse of macros, most code you write using macros in C++ can (and generally speaking should) be written using templated code.
For an example, look at the C #define min
/#define max
vs. the C++ std::min
and std::max
(the C version has so many problems it's not even funny).