So I have a TArray of objects I’d like to iterate over and an iterator seems like the best way to do it. Unfortunately the iterator is advanced by callbacks from background processes, so I’ve been trying to implement the iterator as a class member.
I’m mostly just getting confused and running into syntax errors, but basically: static auto types must be initialized, and I’m not sure what to initialize it with. Or something.
So this is what I started with:
struct MyJobStruct {
JobType Type;
FString ObjectName;
};
and…
static TArray <MyJobStruct> JobQueue;
And the docs suggest:
for (auto Job = JobQueue.CreateConstIterator(); Job; ++Job){
NewJob(Job)
}
So naturally I think I could do:
Header
static auto Job;
C++
MyThing::Job = JobQueue.CreateConstIterator()
Callback
NewJob(++Job)
But obviously I run into initialization problems. If I make Job into a TConstIterator I can no longer access any of the members of my Job struct. How do I do this?