digitalmars.D.learn - How to create immutable struct?
- denizzzka (10/10) Oct 06 2012 I am have struct with constructor:
- denizzzka (1/1) Oct 06 2012 I should just create immutable constructor :-)
- bearophile (8/9) Oct 06 2012 One solution:
I am have struct with constructor: immutable struct Cell { ... } And I trying to create instance of this struct: immutable (Cell)* s = new Cell( v, s); compiler returns error: Error: cannot implicitly convert expression (new Cell(v,s)) of type Cell* to immutable(Cell)* How to pass immutable to new?
Oct 06 2012
denizzzka:How to pass immutable to new?One solution: struct Cell {} void main() { auto s = new immutable(Cell)(); } Bye, bearophile
Oct 06 2012