cristicbz / scid

Scientific library for the D programming language
Boost Software License 1.0
23 stars 8 forks source link

Less fussiness about types when constructing a vector #12

Closed dsimcha closed 13 years ago

dsimcha commented 13 years ago

This one could probably be solved by putting a to!(double[]) or whatever the element type is in. to!(T[])(T[]) simply returns the original T[]. It doesn't copy. Therefore, adding this feature would have zero performance overhead.

import scid.matvec;

void main() {
    auto v = Vector!double([1.0f, 2, 3]);
}

Error:

D:\customd\scid\vector.d(72): Error: constructor scid.storage.array.BasicArrayStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),vectorType).BasicArrayStorage.this (uint newLength) is not callable using argument types (float[]) D:\customd\scid\vector.d(72): Error: struct scid.storage.array.BasicArrayStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),vectorType).BasicArrayStorage member this is not accessible D:\customd\scid\vector.d(71): Error: cannot implicitly convert expression (_param_0) of type float[] to RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1) test9.d(4): Error: template instance scid.vector.BasicVector!(BasicArrayStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),vectorType)).BasicVector.__ctor!(float[]) error instantiating