Talk:Smart pointer

From Wikipedia, the free encyclopedia

This article is within the scope of WikiProject Computer science, which aims to create a comprehensive computer science reference for Wikipedia. Visit the project page for more information and to join in on related discussions.
??? This article has not yet received a rating on the assessment scale.
??? This article has not yet received an importance rating on the assessment scale.
This article is supported by the Wikipedia:WikiProject C++. Please visit the project page for more details on the project.
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


[edit] Example

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)

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

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)