I have an Application class with a std::vector<Monitor> getMonitors() method.
Monitor is a wrapper around a GLFWMonitor*.
getMonitors calls GLFWmonitor** glfwGetMonitors(int* count) to get the pointers, then wraps them into Monitors and returns a vector of them.
I could use the monitor objects to display a list of monitors to the user to select from, to eventually pass a Monitor to my Window class if I want a fullscreen window on that monitor (I can use the GLFWmonitor* to get the monitor name, or to pass it to a window creation function, internally).
GLFW docs say that the GLFWMonitor* pointers can be invalidated when physical monitors are connected/disconnected.
Thus, the returned Monitor objects should be consumed immediately, not stored for later use. I assume "immediately" means "before I call some glfw method that causes it to update its list of monitors".
How do I correctly enforce this limited lifetime of Monitor objects (if at all)?
Should I deal with monitors in some other way than returning a vector of pointer wrappers? Maybe Monitor should contain value copies of all monitor data (instead of containing GLFWmonitor* and using that to get the data) and when I need the corresponding GLFWmonitor* I internally do some kind of reverse lookup using the monitor name for example (are monitor names unique?)