Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] bitwise checks for non-integer types
From: Norbert Wenzel (norbert.wenzel.lists_at_[hidden])
Date: 2017-02-14 17:26:45


On 02/13/2017 05:41 AM, Gavin Lambert via Boost-users wrote:
> I don't think it's generally considered a good idea to test anything
> other than integers using bitwise operations, no.

The main advantage of bitwise comparison of integers (compared to
operator==) in Boost.Test to me is that the error message clearly says
which bit is wrong.

I'd prefer this advantage for any type, though I see a reason to not
allow this type of comparison (especially for floating point numbers).

In case of serialization of arbitrary values a bitwise comparison might
come handy, though the workaround with reinterpret_cast is easy enough
to do in the rare cases one really wants bitwise comparison for
non-integer types.

Thanks for your remarks.

Norbert


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net