www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Casting a pointer and length value as a dynamic array

reply solidstate1991 <laszloszeremi outlook.com> writes:
I need this to port a C++ code to D (a compression algorithm 
known as LZHAM), and the easiest way to deal with it would be 
that. The ADLER32 and CRC32 algorithms had to be ditched, and 
while I could rewrite the former to make sense (used some form of 
"vectorization") I would like to use the standard library's 
implementation for the latter.
Jul 30 2018
parent Jerry <labuurii gmail.com> writes:
On Monday, 30 July 2018 at 22:22:39 UTC, solidstate1991 wrote:
 I need this to port a C++ code to D (a compression algorithm 
 known as LZHAM), and the easiest way to deal with it would be 
 that. The ADLER32 and CRC32 algorithms had to be ditched, and 
 while I could rewrite the former to make sense (used some form 
 of "vectorization") I would like to use the standard library's 
 implementation for the latter.
int[] as_array(int* ptr, size_t len) { return ptr[0 .. len]; }
Jul 30 2018