[Solved] Does C++ standardize the behavior of std::optional under std::min and std::max?


Is something like what I expected standardized in C++17

No.

, or proposed for standardization later?

There is no such proposal in any of the mailings.

Though of course there’s plenty of easy workarounds, so there’s little reason for such a proposal:

oy ? std::max(x,*oy) : x;
x < oy ? *oy : x
*std::max(oint(x), oy)
*std::max<oint>(x, oy)
*std::max(oy, {x})
std::max(x, oy.value_or(x))

There’s probably others. The first two can’t give you a dangling reference, the last four could.

solved Does C++ standardize the behavior of std::optional under std::min and std::max?