static const struct autocast_token { autocast_token(){} } autocast
Provides an easy way to downcast Dynamics without having to specify the downcast target type, and with minimal interruption to the legible program flow.
Type *typed_ptr = dynamic_ptr % autocast;
With template functions like static_cast or dynamic_cast, the target type must be specified twice, i.e.,
MyClass *object = dynamic_cast<MyClass *>(ptr);
”ptr % autocast” returns an object with a template<T> operator T*(), so the target type only needs to be specified once, and the intent of “object = dynamic” is not as interrupted up with silly syntax.