I don't know how to categorize this question precisely, so I'll just explain:
I was googling some stuff for an assignment, and I found what I was looking for, but among the results I checked, I found this one question where I saw so many things I didn't know of/understand: C++ Lambda capture private class member
//...
bool dump_dvars()
{
fstream& refvar{ output_file };
for_each(_array_start, _array_start + *_array_size,
[&refvar](const void* dvar) -> void
{
//work with output_file
});
return true;
}
private:
void** _array_start;
unsigned int* _array_size;
fstream output_file;
};
I don't know what the specific names of each combination are, but I'd like to know what these do:
- fstream& refvar{ output_file };
- [&refvar]
- (const void* dvar)
- -> void
- void**
- unsigned int*
The ones concerning void; I was under the impression that void pointers should be avoided(oh hey, a pun :P), because I read things like the reply to this: List of pointers to different types of objects "Only use a void as a last and very,very dangerous solution."
So what's the use of having a pointer of type void, and a pointer-to-pointer of type void, and accessing the type "void" with lambda?? What does that even do? It's not a variable to fetch stored data from it, what is it accessing? And what would "output_file" do when it isn't assigned a type nor is it stored(so I guess it doesn't return anything, and it isn't returned so it doesn't look like a function), it doesn't have brackets so it doesn't need parameters - it's just an identifier standing there, what does it do? And what does it matter if your int-pointer is unsigned? Aren't all ints like a base class almost(I know int isn't a class) so you can point to another integer with any kind of int? All signed and unsigned integers have the same size when pointing to where in the memory it should be stored i.e. what address, it's just a question of what "direction" or value it will/can hold there.
EDIT:
Attempting to narrow the question down: How does accessing the type "void" work, and what does [&refvar] do?