谁创造了统一(或统一)赋值运算符这个术语?
C++ wiki 书 引用
...在 C++0x 中,这样的赋值运算符被称为统一 赋值运算符,因为它不需要编写两个 不同的赋值运算符...
对于按值获取其类类型的赋值运算符:
String & operator = (String s) // the pass-by-value parameter serves as a temporary
{
s.swap (*this); // Non-throwing swap
return *this;
}
我尝试在谷歌上搜索该术语,但它似乎并未得到广泛使用。
它从哪里来?
A C++ wiki book refers to
... In C++0x, such an assignment operator is known as a unifying
assignment operator because it eliminates the need to write two
different assignment operators ...
for an assignment operator that takes it's class type by value:
String & operator = (String s) // the pass-by-value parameter serves as a temporary
{
s.swap (*this); // Non-throwing swap
return *this;
}
I tried googling the term, but it doesn't appear to be in widespread use.
Where does it come from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它似乎参考了正式类型系统中发生的统一。我们的想法是,如果仅通过某些合法的替换就可以将 r 值和 l 值变为相同类型(统一),则该赋值就是格式良好的。
维基百科声称这个想法首先由 John Alan Robinson 给予了有意义的关注(可能还有它的名字) 。
It appears to be in reference to the unification that takes place in formal type systems. The thought is if the r- and l-values can be brought to the same type (unified) by only certain, legal substitutions, then the assignment is well-formed.
Wikipedia claims the idea was first given meaningful attention (and possibly its name) by John Alan Robinson.
我不确定是谁说的,但维基百科上的书是错误的。 “统一”一词在 c++0x“标准”中恰好出现了零次(现在您确实应该使用短语“C++11”,它于 2011 年 8 月获得批准)。
正确的术语是复制省略。来自 C++0x(n3242,我不用花钱就能得到的最后一个),
12.8 复制和移动类对象,/34
节:I'm not sure who phrased it but the wiki book is wrong. The word "unifying" appears exactly zero times in the c++0x "standard" (you should really be using the phrase "C++11" nowadays, it was approved in August 2011).
The correct term is copy elision. From C++0x (n3242, the last I can get without shelling out money), section
12.8 Copying and moving class objects, /34
: