Hello all. My question has to do with lists.
[LIST EXPLANATION]For the ones who don't know, a list is a set of structs. These structs contain a pointer to the "next" struct, sometimes also to the previous one. There is a special pointer, the head of the lsit, which points to the first element of the list. Thus, all elements can be accesed in such a way: head->next->next->next etc
[END LIST EXPLANATION]
I am trying to create an insertion function template for every possible struct that could be a list member. Initially, I was glad to learn about function templates. There is a problem, however. Different structs will have the corresponding next/previous pointers having various names. How can I pass the names of these members into my function's argument in order to use them? I cannot simply pass the members themselves, because the function edits the members that belong not only to the brand new struct I am inserting each time, but also others on the list (most notably, the ones pointed by head, the previous, and the next).
I had an idea, to use the memory offset of the members in relation to the struct they belong. It really is a headache, void pointers are included, and errors I do get. By the way: I used void pointers in fear that adding the memory offset on them, they would increase in memory offset * sizeof(pointer type) if i gave them a type.
If I am unclear, or you think it would help, i'll paste my code. Really hope you will enlighten me in an easier way though!