For instance,
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
int main() {
std::vector<int> empty{};
std::reverse(empty.begin(), empty.end());
std::cout << "Sum: " << std::accumulate(empty.cbegin(), empty.cend(), 0) << std::endl;
std::cout << empty.size();
}
builds and runs as I expect:
sum: 0
size: 0
Can I be guaranteed this behavior will happen on any standard-compliant compiler?