Getting rid of const/immutable

Cecil Ward d at
Mon Sep 16 05:22:14 UTC 2019

I have a particular type name and that type may or may not be 
const and/or immutable. How do I make a new type based on this 
that is mutable, ie getting rid of both const and immutable, but 
not knowing what the original type is ?

I don’t want to repeat information from the definition of the 
original type as this would introduce a bug if the original 
definition is later changed.

Something like

alias immutable_cash_t = immutable(float);
alias mutable_cash_t = float;

// better, in case the original were ever to be changed from 
‘float’ to ‘real’ some day
alias mutable_cash_t = GetRidOfImmutable!( GetRidOfConst!( 
mutable_cash_t ) );

More information about the Digitalmars-d-learn mailing list