www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16542] New: makeArray not usable with const initializer


          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

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

  // ... 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