Create flow control methods in c++

i was wondering how to create in a function that will imitate the usage of a for loop node in ue4 editor, meaning that calling it in the editor will fire an execution pin for a set amount of indexes and will continue execution with a “completed” pin when it is done iterating. basically, im talking about the mechanism that corresponds to “yield return” in c# .