I want to send events to the main thread from other threads by having the main thread respond to the events it receives after every iteration of its loop.
Is there a way to remove the shared pointer? I don't want to accidentally free the event data before it is used and I don't know how to free it after receiving it whilst still allowing it to use any event data I want. Also is there a way to get rid of the std::vector<int>& threadEventData = *std::any_cast<std::shared_ptr<std::vector<int>>>(threadEvent.data).get(); and std::shared_ptr<std::vector<int>> outputData = std::make_shared<std::vector<int>>(std::initializer_list<int>{1, 2, 4, 6, 7});? I tried using a std::shared_ptr<std::any>>in the event struct but that made it call the move constructor.
I feel like there's an easier way to do this..
code: https://termbin.com/uuzu