Talk:Opaque pointer

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

C++ example[edit]

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. (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 (talkcontribs)
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)
While I agree that the copy-and-swap idiom may be confusing to people not used to modern C++, shouldn't the C++ example at least use a smart pointer? It's about time people learned that raw pointers are not commonly used in C++ anymore. (talk) 13:03, 23 June 2015 (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.

--Heretik 0127 (talk) 01:56, 16 September 2009 (UTC)

Not quite true, in the presence of explicit instantiation. Also, the Intel C++ compiler supports export. decltype (talk) 07:20, 16 September 2009 (UTC)

Mention that d-pointer is also known as Pimpl[edit]

I have never seen anyone around me using d-pointer term to what they did in the C++ example; always heard people referring to this kind of thing as Pimpl idiom. I think Pimpl idiom is more common, so we should mention it? Pranvk (talk) 06:03, 29 October 2018 (UTC)