If I do
std::copy(source, source + size, destination);
Do I have strong exception safety guarantee? I.e. if std::copy throws, destination is left unchanged?
From the standard:
25.3.1 Copy [alg.copy]
template<class InputIterator, class OutputIterator> OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result);1 Effects: Copies elements in the range
[first,last)into the range[result,result + (last -first))starting fromfirstand proceeding tolast. For each non-negative integern < (last -first), performs*(result + n) = *(first + n).2 Returns:
result + (last - first).3 Requires:
resultshall not be in the range[first,last).4 Complexity: Exactly
last - firstassignments.
It does not make any guarantees about exception safety. It also does not specify what the behavior would be if result is in the range [first,last).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With