Shared, ref, arrays, and reserve template instantiation

James Blachly james.blachly at gmail.com
Wed Sep 12 23:41:16 UTC 2018


When I add the "shared" attribute to an array, I am no longer 
able to call reserve because the template won't instantiate:

Error: template object.reserve cannot deduce function from 
argument types !()(shared(int[]), int), candidates are:
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(4091):  
       object.reserve(T)(ref T[] arr, size_t newcapacity)

1. Shared modifies the type, so the template does not match. Even 
casting does not seem to work however. Is there something about 
shared that makes it unable to be taken by reference?
2. Is there a workaround for me to be able to preallocate the 
array?

Kind regards


More information about the Digitalmars-d-learn mailing list