Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-08-04 09:00:12


Gennaro Prota wrote:
> On Fri, 4 Aug 2006 12:00:16 +0100, "Martin Bonner"
> <martin.bonner_at_[hidden]> wrote:
>
>> ----Original Message----
>> From: boost-bounces_at_[hidden]
>> [mailto:boost-bounces_at_[hidden]] On Behalf Of Peter Dimov Sent:
>> 04 August 2006 11:39 To: boost_at_[hidden]
>> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk