digitalmars.D.bugs - [Issue 16542] New: makeArray not usable with const initializer
- via Digitalmars-d-bugs (26/26) Sep 25 2016 https://issues.dlang.org/show_bug.cgi?id=16542
https://issues.dlang.org/show_bug.cgi?id=16542 Issue ID: 16542 Summary: makeArray not usable with const initializer Product: D Version: D2 Hardware: x86_64 OS: Mac OS X Status: NEW Severity: major Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: clumsycodemonkey gmail.com example: --------------------------------------- void doSomething(T)(in T initialValue) { T[] t = theAllocator.makeArray!T(100, initialValue); // won't compile T[] t2 = theAllocator.makeArray!T(100, cast()initialValue); // this one compiles // ... use t and t2 } ----------------------------------------- If all you are doing is copying the value, you shouldn't actually be changing initialValue, so why not make it const? --
Sep 25 2016