M
marco_segurini
Hi,
I like to know if is it possible to use sizeof(T) inside a generic
function.
I don't know why the following function compiles while if I define
ON_LINE_STATEMENT it does not.
generic<typename T>
void CopyArrayFromArray(array<T>^ % vVal, int size
, array<Byte>^ vBytes, int % PosNextValidByte)
{
vVal = gcnew array<T>(size);
pin_ptr<T> ptrDest = &vVal[0];
pin_ptr<Byte> ptrBytes = &vBytes[PosNextValidByte];
#if defined(ONE_LINE_STATEMENT)
const Int32 NumBytesDaCopiare = size * sizeof(T);
#else
Int32 NumBytesDaCopiare = sizeof(T);
NumBytesDaCopiare *= size;
#endif
memcpy(ptrDest, ptrBytes, NumBytesDaCopiare);
PosNextValidByte += NumBytesDaCopiare;
}
TIA.
Marco.
I like to know if is it possible to use sizeof(T) inside a generic
function.
I don't know why the following function compiles while if I define
ON_LINE_STATEMENT it does not.
generic<typename T>
void CopyArrayFromArray(array<T>^ % vVal, int size
, array<Byte>^ vBytes, int % PosNextValidByte)
{
vVal = gcnew array<T>(size);
pin_ptr<T> ptrDest = &vVal[0];
pin_ptr<Byte> ptrBytes = &vBytes[PosNextValidByte];
#if defined(ONE_LINE_STATEMENT)
const Int32 NumBytesDaCopiare = size * sizeof(T);
#else
Int32 NumBytesDaCopiare = sizeof(T);
NumBytesDaCopiare *= size;
#endif
memcpy(ptrDest, ptrBytes, NumBytesDaCopiare);
PosNextValidByte += NumBytesDaCopiare;
}
TIA.
Marco.