Immutable objects and constructor ?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 21 01:24:19 PDT 2016


On 05/21/2016 01:07 AM, chmike wrote:
 > Unfortunately it is not possible to write this
 >
 > import std.typecons;
 > class Info{...}
 > rebindable!Info x;

You have a capitalization typo. Rebindable is a type template, 
rebindable is a function template.

import std.typecons;
class Info{}

void main() {
     auto x = rebindable(new immutable(Info)());
     pragma(msg, typeof(x));

     auto y = Rebindable!(immutable(Info))(new Info());
     pragma(msg, typeof(y));
}

Ali



More information about the Digitalmars-d-learn mailing list