convert *void to void[]
Robert Fraser
fraserofthenight at gmail.com
Wed May 6 02:12:29 PDT 2009
gabrielsylar wrote:
> can anybody please tell me how to properly convert from void* to void[]
> as the code below?
>
> void[] get_bytes(int n) { return sqlite3_column_blob(stmt, n); }
void[] has a length, so you have to know the length. Assuming the length
is n... Maybe try something like this (untested):
struct DynArray
{
public void* ptr;
public size_t length;
public T[] toArray(T)() { return cast(T[]) cast(void*) (*this); }
}
void[] get_bytes(int n)
{
return DynArray(sqlite3_column_blob(stmt, n), n).toArray!(void);
}
More information about the Digitalmars-d-learn
mailing list