为什么交换运营商的提议被否决了?

Why was the swap operator proposal shot down?

Proposal

我不久前读过这篇文章,这听起来是个不可思议的想法。但是,很明显,它还没有进入 C++14,甚至似乎也没有进入 C++17。这是什么道理?

作为背景,您 link 编辑的论文建议将 operator:=: 添加到语言中以完成以下内容今天所做的工作

using std::swap;
swap(a, b);

相反,你会写,

a :=: b;

这由 EWG issue 54 跟踪并被拒绝,因为 不是缺陷 因为尽管有新的运算符,使用对 swap 的不合格调用的技术将持续存在因为没有它,所有用户定义的 swap 函数都将变得毫无用处。此外,添加运算符并不能消除必须依赖 ADL 来查找类型特定 swap 实现(如果存在)的需要。

引用上面 link 中的 Bjarne:

But swap() isn't going away because of backward compatibility, so now we'll have swap() and operator:=:. "Probably a good idea if we had a time machine". Introducing a new operator, it has to be really central and helpful. If it got us out of our swap problem it might be good enough, but it isn't. Libraries aren't going to stop calling swap and if they did then all the specialized swap functions people have written wouldn't get invoked. Problems are real, but the benefits it would have (i.e. what problem it would actually solve) aren't sufficiently explained. Too likely that swap and :=: would coexist indefinitely and that all the problems of swap would persist.

General agreement that this is a real problem but that it's not clear why this would solve them. We will not proceed with this.

No recommendation to move forward, considered NAD.