
On Friday, May 04, 2012 1:04 PM, Richard wrote:
static_cast
(p) where p is void* works perfectly fine. It is always valid to cast a void* to any other type and that's what static_cast<> does -- performs the cast when it is allowed by the rules of the language. You don't need reinterpret_cast<> here.
Did you try it with static_cast?
You learn something new every day. Since static_cast works, then feel free to change my sample accordingly. As for your earlier comment about the only "sane" thing being to cast back to the exact same type after a void* context parameter, that's the main reason why I suggested a generic helper class. My class takes complete control of the Xt callback, thus making it extremely difficult to mess up that cast, and it provides a type-safe interface to your code. Get it working once, and then reuse it whenever you need an XtAppTimeout.