Re: Type safety, C++ and code generation
- From: "REH" <spamjunk@xxxxxxxxxxx>
- Date: 27 Apr 2006 06:19:14 -0700
Maciej Sobczak wrote:
Hi,
I have developed a simple code generator that helps me significantly
raise the level of type safety in C++:
http://www.msobczak.com/prog/typegen/
The whole idea was in some way inspired by Ada, so I hope to get some
constructive criticism and comments from you - that's why I post it
here. Please look at it from the perspective of Ada programmer.
(And taking into account the fact that some of you are also C++
programmers, you might actually find it interesting or even useful.)
--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
You maybe interested in a C++ class that I wrote. It creates range and
overflow checked integer types. The interesting thing about the class
is that it uses templates to do static analysis on expressions to
remove unnecessary checks at compile time.
For example:
typedef ranged_type<unsigned, 0, 100> R;
R x, y, z; // The variables are defaulted to the
// minimum of the range which in this
// case is 0. Sometime later these
// variables are initialized. Their
// actual values do not matter for
// this example.
const R a = 5, b = 7, c = 1;
R r = ((x + a) * (y + b)) / (z - c);
For the above, all overflow checks are removed, except for
divide-by-zero, negative values on the subtraction, and the upper range
of the result when assigning to r.
If you are interested, it can be found here:
http://www.richherrick.com/software/herrick_library.html
REH
.
- Follow-Ups:
- Re: Type safety, C++ and code generation
- From: Maciej Sobczak
- Re: Type safety, C++ and code generation
- References:
- Type safety, C++ and code generation
- From: Maciej Sobczak
- Type safety, C++ and code generation
- Prev by Date: Re: procedural vs object oriented
- Next by Date: Re: procedural vs object oriented
- Previous by thread: Type safety, C++ and code generation
- Next by thread: Re: Type safety, C++ and code generation
- Index(es):
Relevant Pages
|