Its possible something like this already exists in the latest versions of C++ but if so I am not aware of it