C++ 是否标准化了 std::optional 在 std::min 和 std::max 下的行为?

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

我没有安装最新的编译器来获得最终 std::optional 语义的提示。但在 C++14 中,如下:

#include <experimental/optional>
#include <algorithm>

int main()
{
    using oint = std::experimental::optional<int>;
    int x = std::max(1, 2);
    auto oy = oint{3};
    auto z = std::max(x, oy);
}

不编译。现在,在未来,我会 expect/hope 在这种情况下 z 会得到 3;如果 oy = oint{} 那么 z 可以得到 2

是像我期望的那样在 C++17 中标准化,还是稍后提议标准化?或者,undefinability 是否标准化(就像在 C++14 中一样)?

注意:这里的动机可能是我自己为 C++17 之前的代码实现一些东西;如果计划将相关内容标准化,我会尝试匹配它。

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

没有

, or proposed for standardization later?

mailings 中没有任何这样的提案。

虽然当然有很多简单的解决方法,但没有理由提出这样的建议:

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))

可能还有其他人。前两个不能给你一个悬而未决的参考,后四个可以。