const

Oskar Linde oskar.lindeREM at OVEgmail.com
Fri Mar 28 07:45:23 PDT 2008


Janice Caron wrote:
> On 28/03/2008, Oskar Linde <oskar.lindeREM at ovegmail.com> wrote:
>>  1. Plain data types don't need the storage constancy to be a part of the
>>  type.
> 
> But they do, for the following reason. Suppose I implement a custom
> container. Then I would want
> 
>     MyContainer!(char)
> 
> to behave differently from
> 
>     MyContainer!(const(char))
> 
> The only way I can see of achieving this is if char and const(char)
> are distinct types.

I called const/invariant "type meta qualifiers". They are not part of 
the type but carry type meta information. It makes sense that you are 
able to pass the type meta qualifiers to templates that make use of 
them. There is an analogue with how templates today by default strip the 
type meta qualifiers.


-- 
Oskar



More information about the Digitalmars-d mailing list