Re: Type safety, C++ and code generation
- From: Martin Krischik <krischik@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 20:14:53 +0200
Maciej Sobczak wrote:
What about making different types really distinct?
typedef ranged_type<int, 0, 100> R1;
typedef ranged_type<int, 0, 100> R2;
typedef ranged_type<int, 0, 101> R3;
Above, R1 and R2 are equal to the compiler, but R3 is distinct from
the other two. This is or can be problematic in those contexts where you
would rather expect them all to be different from each other -
especially when you think in terms of different *domains*, no matter
what is their range of values.
This is because "typdef" in C++ is "subtype" in Ada. You would need:
class R1 : ranged_type<int, 0, 100> {};
class R2 : ranged_type<int, 0, 100> {};
class R3 : ranged_type<int, 0, 101> {};
to create new types.
Martin
--
mailto://krischik@xxxxxxxxxxxxxxxxxxxxx
Ada programming at: http://ada.krischik.com
.
- References:
- Type safety, C++ and code generation
- From: Maciej Sobczak
- Re: Type safety, C++ and code generation
- From: REH
- Re: Type safety, C++ and code generation
- From: Maciej Sobczak
- Re: Type safety, C++ and code generation
- From: REH
- Re: Type safety, C++ and code generation
- From: Maciej Sobczak
- Type safety, C++ and code generation
- Prev by Date: Re: Type safety, C++ and code generation
- Previous by thread: Re: Type safety, C++ and code generation
- Next by thread: Re: Type safety, C++ and code generation
- Index(es):
Relevant Pages
|