winapi - When using Win32 code in your modern C++ app, should you use proper casting? -


For example, the following cast will remain littered with the entire MSDN documentation:

  (LPTSTR) & Amp; LpMsgBuf  

Should I have trouble in changing this:

  static_cast & lt; LPTSTR & gt; (& LpMsgBuf);  

Or I should just leave 32 pieces of C-eski win with all idioms because they are usually found in docs, and for the rest of my code, more idiotic C + + Can save style / use?

The reason for the new style was introduced for one reason: they are safe, more explanatory / self-comment , Easy

then use it.

By more clarification, we mean that you can only do nothing, you have to say why you are casting (I am in a heritage hierarchy (dynamic_cast) I'm casting, my cast is defined and probably not portable (reinterpret_cast), I'm removing constness (const_cast), etc.).

They are purposefully long and ugly, so the artist jumps out from the reader (and to discourage a programming style to discourage too much).

They are safe because, for example, you can remove the concurrently without any hesitation.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -