This article is within the scope of WikiProject C/C++, a collaborative effort to improve the coverage of C/C++ on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
In the C++ example, I could figure out the vague benefit of swapping a temporary object, but I wouldn't call it completely obvious. It might be especially confusing to people who are only used to seeing const T& as the argument to operator=. If there is an article that discusses that in a bit more detail, it should be linked as the source, IMHO. 184.108.40.206 (talk) 18:09, 12 July 2009 (UTC)
I agree, it's certainly not completely obvious. I have added a clarifying comment. The assignment operator article linked to does mention it. Unfortunately, it is not described in as much detail as one could hope, and there is no source. I'm fairly sure the idiom is mentioned in C++ Coding Standards by Sutter & Alexandrescu, so that could probably be used as a cite. decltype (talk) 18:36, 12 July 2009 (UTC)
Decltype, the clarifying comment says something that I disagree with. I wasn't sure how to modify it to be both accurate and succinct, so I'll just point it out. The passing by value actual causes a temporary to be created, but the comment says that it eliminates a temporary.—Preceding unsigned comment added by Nolancapehart (talk • contribs)
Ah, you're quite right! It is common to refer to any automatic object used to store some intermediate result as a temporary, but that is certainly one misnomer we do not want to propagate. Thanks for pointing out this mistake. decltype (talk) 07:28, 1 March 2010 (UTC)
Guys, this affirmation is definitely wrong: In the example below, the copy assignment operator takes its argument by value, eliminating the need to explicitly create a copy of the other object.. It really does the opposite by creating a new object through the copy constructor; and not to mention it creates a lot of confusion. Iulian.serbanoiu (talk) 08:56, 11 April 2012 (UTC)
In c++, there is a strong limitation about the interface of the object. There can't be any non-exported template methods in the interface of the object. (because non-exported template methods have to be defined in the include file.) And of course, the object itself can't be a template class.
As compiler supporting "export" for template methods is rare (only Comeau c++ compiler today), it may be good to indicate it.