[Issue 16542] New: makeArray not usable with const initializer
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Sep 25 14:50:10 PDT 2016
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 at puremagic.com
Reporter: clumsycodemonkey at 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?
--
More information about the Digitalmars-d-bugs
mailing list