Talk:Smart pointer

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
WikiProject Computer science (Rated C-class, Low-importance)
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles 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.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
WikiProject Computing / Software / CompSci (Rated C-class, Low-importance)
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology 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.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software (marked as Low-importance).
Taskforce icon
This article is supported by WikiProject Computer science (marked as Low-importance).
 
WikiProject C/C++ (Rated C-class)
WikiProject iconThis 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.
C-Class article C  This article has been rated as C-Class on the quality scale.
 ???  This article has not yet received a rating on the importance scale.
 
edit·history·watch·refresh Stock post message.svg To-do list for Smart pointer:

  • Write a concise introduction, with clarification about applicable computer languages (C++, ¿ADA?)
  • Clarification about the term "handle"
  • Add a History section, with origins, development, drawbacks and standarization efforts.
  • Add a Examples section, with a comparative, simple example of use

Example[edit]

I have included an example in C++ language. Note I was aware of WP:MOS#Avoid_first-person_pronouns_and_one. I thought first person was suitable because the comments behave as a mathematical deduction.

I have tried to make the example independent from whether the approach is intrusive, so it does not depend on the counter being stored into the object, as well as it does not depend on the counter being stored into the smart pointer. For instance, q = obj_1; instead of q = p; will not work in the latter case.

Also, the following will not work with some implementations (as stated by Alexandrescu, Modern C++ Design) so I modified the example for compatibility with the general case.

Object* obj_1 = new Object();		
SmartPointer<Object> p= obj_1;			
SmartPointer<Object> q= obj_1;			

Rjgodoy 16:12, 29 May 2007 (UTC)

I would like your opinion about this paper (in Spanish). It contains an analysis of drawbacks which could be useful in the article (sections 3 and 4). However, since I'm one of the authors of that work, I submit it for discussion, per WP:COI. Rjgodoy 23:25, 29 May 2007 (UTC)


Um.... i'm going to fix this, no offense. Revert if you want, i won't be back to keep an eye on the page. have you heard of WP:NOTGUIDE - wikipedia is not a tutorial .'. doen't use instructional examples, in general terms. -Oxinabox (talk) 04:33, 1 January 2009 (UTC)

track of the objects that point to them/they point[edit]

The wording "[SPs] keep track of the objects that point to them" instead of "[SPs] track of the objects that they point" is intentional. A SP tracks how many objects are actually pointing *it* (because the raw pointer cannot track them by itself) and each SP usually manages only one object. Besides of some quirks, it seems as if the outer objects were pointing to the target object, but they are pointing to the SP. I hope the distinction is clear.

Rjgodoy (talk) 11:37, 14 May 2008 (UTC)

Jagat sastry wrote: "But isn't the smart pointer supposed to point to the object whatsoever?"
In short, the answer to your question is yes, they point to the target object, but they track how many references (to the smart pointer, and indirectly to the target object) are in scope at any given moment. The target object itself is not tracked but managed. Rjgodoy (talk) 02:59, 15 May 2008 (UTC)

Well, yeah. That does make sense. Nice word Rjgodoy!

Jagat sastry (talk) 07:50, 15 May 2008 (UTC)

Dead link[edit]

The Link 'Article "The New C++: Smart(er) Pointers" by Herb Sutter' does not lead to the article. —Preceding unsigned comment added by 217.88.205.48 (talk) 21:42, 24 August 2010 (UTC)

Fixed. Sebastian Garth (talk) 21:50, 24 August 2010 (UTC)

Øøh, cool![edit]

A large bunch of code, coOOOol! For nerds like me, that is. However I would wager that not everyone reads C++ fluently. Maybe perhaps instead the general principles could possibly be explained in English? Rursus dixit. (mbork3!) 15:57, 14 October 2010 (UTC)