
On Wed, 9 Mar 2011 09:41:58 -0500 "Stewart, Robert" <Robert.Stewart@sig.com> wrote:
Why can the comparison operators throw? I would have expected that they could be implemented to never throw.
So far as I know, the only reason they would ever throw is if they're passed a Not-a-Number value, or if something unpredictable has gone seriously wrong.
I would hope you could be more definitive than that and clearly document the behavior.
I can be definitive about the Not-a-Number behavior, and anything else that I put into the code. I can't be definitive about anything unpredictable. Out-of-memory isn't a problem in the comparison functions, but it's probably the most common example of stuff that can go wrong unpredictably.
magnitude_t: * It probably needs to be POD for you to make assumptions about the layout.
The "struct hack" is a standard C idiom [...]
A C struct is POD.
So far as I've been able to determine, a C++ struct with some non-virtual functions, and that doesn't inherit from anything, acts like POD in every case. There's no need for a vtable or any other appended data that I've been able to imagine, and there certainly isn't on the two compilers I've directly tested (MSVC on Windows and GCC on Ubuntu Linux). -- Chad Nelson Oak Circle Software, Inc. * * *