On 16.02.2016 01:14, H. S. Teoh via Digitalmars-d wrote:
Just out of curiosity, since we already have Rebindable in Phobos and HeadConst is being proposed, what are the disadvantages / shortcomings of a library solution that would justify adding yet another feature to the language?
struct S{ int[] a; void foo()headconst{ a[0]=1; // ok // arr.length=2 // error } } void main(){ headconst(S) s([0,2,3]); s.foo(); assert(s.a==[1,2,3]); } How to do this in the library?