Boost logo

Boost :

Subject: Re: [boost] Is there interest in portable integer overflow detection, with policy based handling?
From: Ben Robinson (cppmaven_at_[hidden])
Date: 2012-02-21 21:00:23

On Tue, Feb 21, 2012 at 9:18 AM, Antony Polukhin <antoshkka_at_[hidden]>wrote:

> 2012/2/21 Ben Robinson <cppmaven_at_[hidden]>:
> > The implementation is fully portable, and it provides integer types which
> > can be used like the builtin integers, except they will trigger their
> > policy on an overflow.
> Great!
> Overflow detections are widely used in Boost.Lexical_cast library, but
> the implementation is not generic. I would very appreciate a header
> only library for detecting overflows.

Well now you have it! :)

> How fast is your library? Does it support unsigned long long int
> overflow detection?

The library is meta-programmed with respect to the data types involved in
each overloaded math operation, taking advantage is performance savings,
such as when both data types are unsigned (see my more complete performance
response above to a previous email).

Addition overflow detection for example involves a single subtract, along
with from one to three compares.

The library is currently implemented over the following data types:

uint8_t, uint16_t, uint32_t uint64_t, int8_t, int16_t, int32_t int64_t.

Some of the template specializations for overflow detection were tricky for
the 64-bit types, given the issues with negative, maximum range values.
These specializations exist and are fully unit tested.

Thank you,

Ben Robinson

> Best regards,
> Antony Polukhin
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at