On Mon, 2025-06-09 at 22:21 +0300, Avi Kivity wrote:
On Mon, 2025-06-09 at 16:04 +0300, Ville Voutilainen wrote:
On Mon, 9 Jun 2025 at 14:17, Avi Kivity <avi@scylladb.com> wrote:
The Standard should not make decisions that cannot be implemented. But it also should not refrain from making decisions that cannot be implemented optimally on every platform, and instead leave it to the platform to make a choice.

Well, that leads to this question: would you like it to be portably
reliable that destroying a vector<optional<vector<optional<string>>>>
is fast, or would you like
it to be theoretically but not practically fast?



That's a good question.


Actually, there's no problem. Eliding the branch in std::optional's destructor doesn't trigger all downstream destructors, just the next one down the line. So instead of the branch in std::optional you'd see the branch in std::vector (or rather, operator delete) but you're still ahead in terms of branch predictor resource consumption.