[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <1D97E025367AFB4A8C528590A3715BF442603B@archerysummit2.willamette.charteroaksystems.com> thusly:
On Thursday, May 03, 2012 2:42 PM, Richard wrote:
boost-users@lists.boost.org spake the secret code <1D97E025367AFB4A8C528590A3715BF442603A@archerysummit2.willamette.charte roaksystems.com> thusly:
static void Internal_callback (XtPointer self, XtIntervalId*) { reinterpret_cast <AppTimeout*> (self)->callback();
I don't know why people always leap to reinterpret_cast<> as their first choice; it's the most dangerous. I'd prefer static_cast<> here.
In this case, the reinterpret_cast is needed because X11 specified that your callback *must* take a void pointer.
static_cast<T*>(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? See "C++ Coding Standards" by Sutter and Alexandrescu, items: 92. Avoid using reinterpret_cast 95. Don't use C-style casts -- "The Direct3D Graphics Pipeline" -- DirectX 9 version available for download <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/> Legalize Adulthood! <http://legalizeadulthood.wordpress.com>