I am using std::copy to copy the objects in std::deque to a file. The code is working fine but I need to check if copying was successful and accordingly I need to set the flag or else throw exception.
I have googled but could not find the solution how to check if std::copy has successfully copied the values into the file.
Could someone please throw a light on it.
If writing to the file fails, then the file stream’s error flags will be set – you can either check these after the copy, or call the
exceptionsmember function first to make it throw an exception on error. If anything else fails, then an exception will be thrown.