
Gennaro Prota wrote:
On Fri, 4 Aug 2006 12:00:16 +0100, "Martin Bonner" <martin.bonner@pitechnology.com> wrote:
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Peter Dimov Sent: 04 August 2006 11:39 To: boost@lists.boost.org Subject: Re: [boost] Portable signbit macro/function?
Johan RĂ¥de wrote:
I still find it hard to believe that the volatile are needed ;-)
It is not.
If volatile is not present, then you can't instantiate the template with T="volatile float" for example. (Similarly you need the "const" so that you can invoke with T="const float".)
I suspect that for this application that doesn't matter, but that Gennaro was so used to using the safe form: reinterpret_cast<const volatile char*>(&s) to get at the bytes of an object in a template, that he just wrote it automatically.
Yes :-)
One might make the argument that adding volatile (automatically) almost never leads to safety of any kind. :-)
And I didn't use boost::addressof because it uses char, not unsigned char (there are endless debates here, especially after C99 has made some properties of signed char explicit; in any case you are safe at home with unsigned; God knows where you are with plain char).
You are safe with plain char, see 3.9/2, although unsigned char is arguably a better practice style-wise.