Casting away immutability

Sergei Degtiarev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 3 09:05:31 PDT 2015


On Thursday, 3 September 2015 at 14:36:12 UTC, Mike Parker wrote:
>
> immutable(T)[] getGetData(T)() {
>     return cast(immutable(T)[])data;
> }
>

Absolutely, instead of returning raw void[] and allow user to 
cast it, std.mmfile should implement template function to return 
desired type.
This would allow all necessary checks inside the module, 
returning pure result.



More information about the Digitalmars-d-learn mailing list