On 08/08/2015 07:07 PM, Jay Norwood wrote:
> On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote:
>> // NOTE: No need to tell rawRead the type as double
>> iota(10, 20_000_000 + 10, n)
>> .each!(a => f.rawRead(dbv));
>> }
>>
>> Ali
>
> Your f.rawRead(dbv) form compiles, but f.rawRead!(dbv) results in an
> error msg in compiler error in 2.067.1. The f.rawRead!(double)(dbv)
> form works.
rawRead is a member function template with one template parameter and
one function parameter:
T[] rawRead(T)(T[] buffer);
The single template parameter T is the element type of its function
parameter, which is a dynamic array.
In this case, function template type deduction works and the template
parameter need not be provided because dbv is of type double[] and it is
obvious that T is double:
f.rawRead(dbv) // <- compiles
It is the same thing as proving T explicitly as double:
f.rawRead!(double)(dbv) // <- compiles
The code that does not compile has an error because it provides dbv as a
template argument (because it is in the parameter list that comes right
after !):
f.rawRead!(dbv) // oops, dbv should be the function argument not
the template argument
Ali