Containers

deadalnix deadalnix at gmail.com
Wed Sep 1 12:49:46 UTC 2021


On Wednesday, 1 September 2021 at 11:04:41 UTC, Steven 
Schveighoffer wrote:
> It's possible to forward, i.e.:
>
> ```d
> template Vector(T) if (isConst!T) { alias Vector = 
> tailconst(.Vector!(Unqual!T)); }
> ```
>
> If you look at arrays, `const(T)[]` is the same as 
> `tailconst(T[])`. This would be similar.
>
> The problem I have with any other approach is that the compiler 
> doesn't understand the relationships, and you will run into 
> weird corner cases. It can't correctly add or strip the 
> qualifier to the correct members when calling compatible 
> functions.
>
> -Steve

If the type is unrelated, then you are back to the heuristic 
problem.


More information about the Digitalmars-d mailing list