Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-08-03 07:09:46


At 09:06 PM 7/28/99 +0100, Kevlin Henney wrote:

>The alternative is to provide a template based solution, rather than
death
>by a thousand typedefs/#defines. I did something like this, and
outlined
>the details in a couple of articles for Overload when Sean was
editing it a
>few years ago. I'd be happy to dig it up and submit the code as a
library.
>
>Thoughts?

My first response to Kevlin was perhaps unfairly negative. Maybe we
ought to explore the alternatives to the C stdint.h header a bit. If
there is a better way, we should at least consider it.

The possible approaches I can see are:

* A template approach where the user would write code like:

     int_t<32>::exact // to obtain the 32-bit integer type
     int_t<32>::max() // to obtain the maximum value

* A typedef and constant approach where the user would write:

     int32 // to obtain the 32-bit integer type
     INT32_MAX // to obtain the maximum value

While the template approach seems conceptually more elegant, I find
the resulting user code unbearably ugly. The typedef and constant
approach is basically stdint.h without the macros, a nice advantange.

Kevlin, what did your template approach look like?

Are there other possiblities?

--Beman


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