|
Boost : |
Subject: Re: [boost] Proposed templated integer_sort
From: Steven Ross (spreadsort_at_[hidden])
Date: 2009-02-02 17:14:38
On Mon, Feb 2, 2009 at 1:47 AM, Phil Endecott <
spam_from_boost_dev_at_[hidden]> wrote:
>
> I've added these static assertions in the casting methods:
>> BOOST_STATIC_ASSERT(sizeof(cast_type) == sizeof(data_type));
>> BOOST_STATIC_ASSERT(std::numeric_limits<data_type>::is_iec559);
>> BOOST_STATIC_ASSERT(std::numeric_limits<cast_type>::is_integer);
>> That should guarantee I'm casting an IEEE floating-point number to an
>> integer of the same size.
>>
>
> I was imagining that you'd use these to enable a specialisation, e.g. using
> enable_if, rather than in asserts.
> <http://lists.boost.org/mailman/listinfo.cgi/boost>
>
I suppose I could call just call std::sort for situations where any of those
asserts would fail, but I think a compile error is more appropriate. Can
you think of a usage case with a standards-compliant C++ compiler where
someone would want to use float_sort but those assertions fail for a reason
other than user error?
If not, I believe telling the user that they're using it wrong via a static
assertion failure is more appropriate.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk