View Single Post
Old 20th June 2017, 17:10   #449  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
something I failed to understand
Code:
const int *pA = array + 2;
what's that "+2"? some kind of offset value? will it be affected if I change the structure of vector stream? like if I change "sad" in the vector to double?

and this,
Code:
pA += pA[0];
I suppose it should be something like
Code:
constexpr auto StreamHeaderOffset = 2;
auto pA = reinterpret_cast<const VectorStructure *>(array + StreamHeaderOffset);
auto MoveOnToTheNextVector = [](auto &VectorPointer) {
	constexpr auto AbsoluteVectorSize = sizeof(std::decay_t<decltype(*VectorPointer)>);
	constexpr auto RelativeVectorSize = AbsoluteVectorSize / sizeof(int);
	auto ForwardDistance = VectorPointer->x / RelativeVectorSize;
	VectorPointer += ForwardDistance;
};
MoveOnToTheNextVector(pA);
?

and that's why I hate C and old C++ so much cuz it's like fucking deciphering assembly code, what's so hard about defining weird constants with constexpr variables with proper names and writing some nested closure functions to tell others what the hell you're doing exactly?

Last edited by feisty2; 20th June 2017 at 17:36.
feisty2 is offline   Reply With Quote