Boost logo

Boost :

Subject: Re: [boost] SafeInt code proposal
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-20 19:46:01


AMDG

Omer Katz wrote:
> A friend and I have started working on a SafeInt library which we hope
> will be included in Boost
>
> the library is composed of a template class, which excepts existing
> integer types as a parameter, and an exception class.
> not all operators have been implemented and there is still work to be
> done on the library, but we have reached a stage in which at least the
> basic operators are ready and tested.
>
> I've attached to this thread a zip file containing the code for the
> library and a tester we wrote (as an example for how the class should
> be used)
> I've also uploaded it to the boost vault.
>
> We would appreciate it if you took the time to review our code and
> give us your comments, tips and opinions (either as a reply to this
> thread or by email - omerktz_at_[hidden])

* Use Boost style naming conventions (i.e. safe_int, not SafeInt).
* Don't use exception specifications.
* Use functions instead of macros.
* use std::numeric_limits<T>::min/max() instead of computing it for
yourself.
* long long is not portable
* It's better to use non-members for operator+, operator-, etc.
  It's odd that you overload for SafeInt<T>() + S, but not S + SafeInt<T>().

In Christ,
Steven Watanabe


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