First off, no I am not a student…just a C# guy porting a C++ library.
What do these two crazy lines mean? What are they equivalent to in C#? I’m mostly concerned with the size_t and sizeof. Not concerned about static_cast or assert..I know how to deal with those.
size_t Index = static_cast<size_t>((y - 1620) / 2);
assert(Index < sizeof(DeltaTTable)/sizeof(double));
y is a double and DeltaTTable is a double[]. Thanks in advance!
size_tis a typedef for an unsigned integer type. It is used for sizes of things, and may be 32 or 64 bits in size. The particular size of asize_tis implementation defined, but it is unsigned.I suppose in C# you could use a 64-bit unsigned integer type.
All
sizeofdoes is return the size in bytes of a C++ type. Every type takes up a certain quantity of room, andsizeofreturns that size.What your code is doing is computing the number of doubles (64-bit floats) that the
DeltaTTabletakes up. Essentially, it’s ensuring that the table is larger than some size based ony, whatever that is.There is no equivalent of
sizeofin C#, nor does it need it. There is no reason for you to port this code to C#.